Hi:
I'm working on a LPC1768 board with MDK-4.11 and RTX-4.11, I sent some debug messages to Debug(printf) viewer window simply by ITM_SendChar(), it works well before I use RTX. but when I use this function in a RTX task, the execution hang in HardFault_Handler of startup_LPC17xx.s. I can show this with following code snippet from the Keil example RTX_Blinky. Somebody pls help out, Thx a lot.
int main (void) { SystemInit(); /* Initialize the MCU clocks */ LED_init (); /* Initialize the LEDs */ GLCD_Init(); /* Initialize the GLCD */ GLCD_Clear(White); /* Clear the GLCD */ /*! debug test begin */ ITM_SendChar('M'); /* Here,"M" disply in viwer correctlly before RTX init */ /*! debug test end */ os_sys_init(init); /* Initialize RTX and start init */ } __task void phaseA (void) { for (;;) { os_evt_wait_and (0x0001, 0xffff); /* wait for an event flag 0x0001 */ LED_On (LED_A); signal_func (t_phaseB); /* call common signal function */ LED_Off(LED_A); /*! debug test begin */ ITM_SendChar('A'); /* Here,"A" doesn't appear in viewer, program hangup in HardFault_Hander*/ /*! debug test end */ } }
Is "CoreDebug" valid? I played with this once, but I don't remember if some initialization is required!
Eventually I found the reason, RTX creates unpreviliged tasks by default, all access to control/config and specail registers by unpreviliged code shall trigger a hard fault. so if user tasks want to sent out data via ITM_SendChar, they should issue a system call (ie.,SVC in CM3),ask kernel do it for them. I don't know if printf is implemented in this way? this makes something act like linux.
Regards.