is not unsigned int a volatile ? since I define it under the include headers directly . where can I fine the type of definisions for keil for the new lib 3.4 ?
sorry I am back with new question , exuce me I am new to cortex m3 and STM
my system coreclock is 72Mhz , I want the system tike inturrept every 5ms so how can I calculate this what is the formula? what is the relation between tick and ms? if(SysTick_Config(SystemCoreClock / x) ) // 5ms interrupts x=? the formula please . Thank you
Posted on May 17, 2011 at 14:27 Thank you it is solved , so is not better to define all variables as volatile ? what is the diffrent between static and volatile in this case ? Thank you all in advance Regards
is not unsigned int a volatile ? since I define it under the include headers directly .
No, being external or publically defined is not the same as being volatile, which infers that it might change between different reads. Like a hardware register, or interrupt incremented counter. volatile unsigned int delay_main;
Tips, Buy me a coffee, or three.. PayPal VenmoUp vote any posts that you find helpful, it shows what's working..
what is the relation between tick and ms? what is the diffrent between static and volatile in this case ?
1/1000 th of a second is 1ms, x = 1000 5ms period is 1000/5 thus x = 200, ie 5/1000 th of a second or 1/200 th of a second. Measured in 72 MHz cycles, where 72000000 cycles per second 72000 cycles per millisecond, and 360000 cycles per 5 milliseconds. A static is invisible outside the current object file. You should use volatile if the value changes independent of program flow. ie in an interrupt. If you call a subroutine it is assumed variables will change. You could also turn off optimization, and then the compiler wouldn't hold variables in registers, or reduce loops.
Tips, Buy me a coffee, or three.. PayPal VenmoUp vote any posts that you find helpful, it shows what's working..
Posted on May 17, 2011 at 14:27 Thank you my problem is this if(SysTick_Config(SystemCoreClock / 1000) ) // 1ms interrupts now I get every 1ms an interupt; in the system tick handle I increment main_delay++; then in the main routine I check while(main_delay<3000); this should wait 3 sec but it wait about 10 sec . what could be the problem ? again thank you clive