Hi, I am not sure, If I did not asked before, but forum search has not found anything.
I am new in CooCox and ARM, I worked with AVRs before. What I miss in CooCox is "delay.h" lib similar to AVR GCC. I hnow, that I can use SysTimer for milisecond delays, but what are you using for micro second delays? (something like _delay_us)
My current solution is:
void _delay_us(uint16_t nTime)
TIM3->CNT = 0;
while ( (TIM3->CNT) < nTime);
where TIM3 si set for us clock
// 1 MHz clock
TIM_TimeBaseStructure.TIM_Prescaler = 21 ; // I have 22MHz clock
TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up;
//TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Down;
TIM_TimeBaseStructure.TIM_Period = 0xFFFF;
TIM_TimeBaseStructure.TIM_ClockDivision = 0;
// Set one shot
/* TIM2 enable counter */
It is clear, that it is not accurate for very short delays. But my typical delays are longer than 10us.
Is this OK, or you have some better solution?