Timer interrupt example?

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
cohuc_3807591
Level 3
Level 3
5 likes given First like given

Hello:

Is there any examples on how to define/use ISRs in WICED for microsecond level sampling? This has been asked many times in the forum, but the only answer is to use the rtos_delay_microseconds() function. This method wont work for fixed sampling rate applications as there is a chance that function takes much longer than the passed time to return.

app info: every 5 usec I want to do a spi read to take an adc sample to achieve a sampling rate of 100khz. Im lloking for an example that defines a timer interrupt and how to use it. Thanks.

0 Likes
1 Solution

The timer in 43907 can only get a millisecond interrupt. There isn't API to access the low level timer settings.

View solution in original post

0 Likes
5 Replies
Owen_Zhang123
Moderator
Moderator
Moderator
5 questions asked 500 solutions authored 250 sign-ins

Which device are you using? Could you try the API wiced_result_t wiced_rtos_init_timer( wiced_timer_t* timer, uint32_t time_ms, timer_handler_t function, void* arg ).

And there is some demo code under snip/bluetooth/serial_gatt_service.

Hey OwenZ_26​:

Thanks for the reply. For our device we are targeting the CYW43907 chip.  I've checked out the rtos_timer function as you mentioned, but the time isn't granular enough. To support 100kHz we would need a timer of 5 usec - way smaller than a msec.

0 Likes

Sorry, there isn't a microsecond timer interrupt for this device.

0 Likes

OwenZ_26

Is there a way I could make one? Im imaging that there is a register that is incremented at each clock cycle, and when it hits a certain number (whatever corresponds to 1 or 5 or even 10 usec) I execute my ISR.

What is the shortest timer interrupt available on the 43907?

I see that the rtos_timer calls a threadx function _txe_timer_create - is there a lower bound on the amount of time this can watch for?

0 Likes

The timer in 43907 can only get a millisecond interrupt. There isn't API to access the low level timer settings.

0 Likes