device_reboot failed

Sub forums for various specialist XMOS applications. e.g. USB audio, motor control and robotics.
Post Reply
dengzicheng
Junior Member
Posts: 7
Joined: Sat Mar 12, 2016 10:08 am

device_reboot failed

Post by dengzicheng »

I am developing a project now, but I have a very strange problem, about device_reboot.
A brief description is as follows:
In the project, there are two threads. 1. I2S send data part 2. Button detection
When the button detects a certain state, the XMOS device needs to be automatically restarted.In most cases, device_reboot works fine. But in a special case, device_reboot fails.
This special case is: when a certain burst condition, the MCLK clock is disconnected.At this time, the Audio thread is blocked.Then, due to the triggering of the button detection, the device needs to be restarted,restart failed.From the situation of my test, Only the MCLK clock is normal to restart successfully.I understand that device_reboot should be similar to a hardware reset operation, but the actual situation does not seem to be the case.It seems to have a big difference with the hardware reboot.Is there a way to force XMOS to reset, similar to manually pressing the reset button?


User avatar
mon2
XCore Legend
Posts: 1913
Joined: Thu Jun 10, 2010 11:43 am
Contact:

Post by mon2 »

Hi. Please review this thread:

https://www.xcore.com/viewtopic.php?t=3539
dengzicheng
Junior Member
Posts: 7
Joined: Sat Mar 12, 2016 10:08 am

Post by dengzicheng »

Thank you very much for your reply. I think I know how to reset the XMOS chip. Because in most cases, I can reset successfully.The chip is:XU216-512-TQ128-C20
I will describe in detail the problems I have encountered.The following is the function I am using
/* Reboots XMOS device by writing to the PLL config register */
void device_reboot(void)
{
unsigned int pllVal;
unsigned int localTileId = get_local_tile_id();
unsigned int tileId;
unsigned int tileArrayLength;

asm volatile ("ldc %0, tile.globound":"=r"(tileArrayLength));

/* Reset all remote tiles */
for(int i = 0; i < tileArrayLength; i++)
{
/* Cannot cast tileref to unsigned */
tileId = get_tile_id(tile);

/* Do not reboot local tile yet */
if (localTileId != tileId)
{
read_sswitch_reg(tileId, 6, pllVal);
pllVal &= 0x7FFFFFFF; // Mask the XS2 no reset bit
write_sswitch_reg_no_ack(tileId, 6, pllVal);
}
}

/* Finally reboot this tile */
read_sswitch_reg(localTileId, 6, pllVal);
pllVal &= 0x7FFFFFFF;
write_sswitch_reg_no_ack(localTileId, 6, pllVal);
}
My project is briefly described as follows:
void key_handle(unsigned int key_fun_count)
{
switch(key_fun_count)
{


case FRE_44:
SET_SHARED_GLOBAL(g_fre_value_audio,44100);
SET_SHARED_GLOBAL(g_word_clk_open_flag,0);
x = 0x55;
asm volatile("stw %0, %1[0]" :: "r"(x), "r"(FLAG_ADDRESS));
transmitter(1);
SET_SHARED_GLOBAL(g_word_fre_value_audio,200000);
device_reboot();
while (1);
break;
//................................
//...............................

default:
break;

}
}

void audio()
{
//.........................
//.........................
//.........................
}

If the audio thread is blocked, for example, MCLK is disconnected.key_handle working normally.Then the button is triggered and I need to restart the XMOS chip.But the restart failed in this state.
Post Reply