Using a TMS470R1B1M board designed by myself, Non RTX program runs fine within and without flash, but when added RTX,os_dly_wait() and os_itv_wait() refuse to run in flash mode while they work sucessfully in debug mode. The flash.ini and flash_debug.ini are the same with samples provided by MDK, please give me an answer source codes follows:
/**********************************************************************************************************************/ /**********************************************************************************************************************/ #include "includes.h" DEVICE_CLKS *pDeviceClks; char strSciBuf[256]; OS_TID tidTime; OS_TID tidClock; OS_TID tidLed; OS_TID tidAdc; OS_TID tidSci; struct time_s { unsigned char h; unsigned char m; unsigned char s; } current_time; regSPI_t *pspi; ADS1278_APP pAdc; s32 AdcBuf[8]; u8 AdcBytes[24]; double AdcValue[8]; /* HET RAM start (dependant on MFBAHR4 value in TMS470R1B1M.s) */ #define HET_RAM 0x40000000 volatile HETPROGRAM0_UN e_HETPROGRAM0_UN __at(HET_RAM); //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // void delay(s32 lps) { vs32 i; for(i=0;i<lps;i++); } //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //This function copies 32-bit values to destination from source addresses of size also given as parameter void memcopy32 (unsigned int *dest, unsigned int *src, unsigned int size) { size >>= 2; while (size--) *dest++ = *src++; } //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // __task void TaskTime (void) { for (;;) { os_dly_wait (100); /* wait for 100 clock ticks = 1 s */ if (current_time.s++ > (60-2)) { current_time.s = 0; if (current_time.m++ > (60-2)) { current_time.m = 0; if (current_time.h++ > (24-2)) { current_time.h = 0; } } } } } //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // __task void TaskLed (void) { static int m=0; GIO_OutEnBits(LED_GIO,LED_PIN,true); os_itv_set(50); for (;;) { if(++m%2==0){ sprintf(strSciBuf,"\r\nledon = %d\r\n",m); GIO_ClrBits(LED_GIO,LED_PIN); }else{ sprintf(strSciBuf,"\r\nledoff = %d\r\n",m); GIO_SetBits(LED_GIO,LED_PIN); } os_itv_wait(); } } //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // __task void TaskAdc (void) { s32 i; CLK_SetClkOut(CLKSR_ICLK); pDeviceClks = CLK_GetClocks(CRYSTAL_FREQ); //8Mhz SPI_SetClk(pSpiA,pDeviceClks->IClk,pDeviceClks->IClk/1000000L); SPI_OpenMaster(pSpiA,8,0,1); ADS1278_Init(&pAdc); pAdc.Open(1234); pAdc.Conv(0);delay(1000); pAdc.Conv(1); for (;;) { pAdc.Read(AdcBuf,4); for(i=0;i<4;i++){ AdcValue[i]=(double)AdcBuf[i]*2.500/(double)S32_MAX; } sprintf((char *)strSciBuf, "ASC%+06.3f,%+06.3f,%+06.3f,%+06.3f\r\n",AdcValue[0],AdcValue[1],AdcValue[2],AdcValue[3]); } } //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // __task void TaskSci(void) { int len; pDeviceClks = CLK_GetClocks(CRYSTAL_FREQ); //8Mhz SCI2_Open(pDeviceClks->IClk,9600); SCI2_SetSciClk(true); EchoInfo(); for(;;){ len = strlen((char *)strSciBuf); if(len>0){ SCI2_SendBytes((u8 *)strSciBuf,len); strSciBuf[0]=0; os_dly_wait(1); } } } //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // __task void TaskInit (void) { current_time.h = 0; /* Initialize current time to 0 */ current_time.m = 0; current_time.s = 0; GIO_OutEnBits(USB_ON_GIO,USB_ON_PIN | (1<<0),true); GIO_SetBits(USB_ON_GIO,USB_ON_PIN); pHET->HETGCR = 0x00010002; /* Clock master + ignore suspend */ /* Copy HET program from code memory to HET RAM */ memcopy32 ((unsigned int *) &e_HETPROGRAM0_UN, (unsigned int *) HET_INIT0_PST, sizeof(HET_INIT0_PST)); pHET->HETDCLR = 0x000000FF; /* Clear HET0..7 */ pHET->HETDIR = 0x000000FF; /* Setup HET0..7 as outputs */ pHET->HETPRY |= (1 << 1); /* Interrupt priority for HET1 */ pHET->HETPFR = 0x0000052B; /* Set prescale factor */ pSM->REQMASK |= (1 << 7); /* Enable HET interrupt 1 */ pHET->HETGCR |= 0x00000001; /* Start HET */ tidSci = os_tsk_create (TaskSci, 1); tidLed = os_tsk_create (TaskLed, 1); tidTime = os_tsk_create (TaskTime, 1); //tidAdc = os_tsk_create (TaskAdc, 0); os_evt_set (0x0001, tidLed); /* send signal event to task phaseA */ os_tsk_delete_self (); } //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // int main (void) { CLK_SetClkOut(CLKSR_ICLK); GIO_OutEnBits(LED_GIO,LED_PIN,true); GIO_OutEnBits(KEY_GIO,KEY_PIN,false); os_sys_init (TaskInit); /* Initialize RTX and start init */ }
output form sci: ledoff = 1 it looks like os_itv_wait() stopped in flash mode,why?
Hello,
Are you sure you but the IRQ handlers the correct place, Flash/Ram ??
IN STM32 i believe you have to move the handlers in the startup file(maybe automatic) but you also have to tell the uC you have moved the vectors
Maybe that could be your problem?
Kasper
Thanks for reply! I tried the example program named RTX_Blinky and provided by MDK 4.12,just modified PORT E to A and commented the lcd function according to my board. The result was: Led linked in debug mode and no change in flash mode. I just wonder, whether keil tested their example before they release it, or whether i am using the wrong version of MDK.
I even added RTX source code files to project and selected "operating system" to "none", but thers's no difference.
INTERRUPTS MAKES ME CRAZY! GOD SAVE ME!