Products > Programming

delays for ARM

(1/5) > >>

Simon:
i am writing a library to talk to the hitachi LCD controller. I see that i would need to assert signal for some ns, even at 48MHz that is hardly worthy of doing any timer based go aways and come back's as it's a couple of clock cycles.

There is i see no standard delay function for ARM. I expect i need to write my own. Anything to be aware of? I take it I need to run some sort of loop that just goes round in circles "x" amount of times based on F_CPU.

tggzzz:

--- Quote from: Simon on September 28, 2019, 04:49:54 pm ---i am writing a library to talk to the hitachi LCD controller. I see that i would need to assert signal for some ns, even at 48MHz that is hardly worthy of doing any timer based go aways and come back's as it's a couple of clock cycles.

There is i see no standard delay function for ARM. I expect i need to write my own. Anything to be aware of? I take it I need to run some sort of loop that just goes round in circles "x" amount of times based on F_CPU.

--- End quote ---

If there are caches or interrupts, they could introduce jitter.

Simon:
Well I don't have a problem with the display data transaction being delayed by interupts. It's a case of a signal needs asserting for a minimum time like 200ns (10 ticks at 48MHz) but if that has to be delayed by an interrupt so be it.

Kjelt:

--- Quote from: Simon on September 28, 2019, 04:49:54 pm ---Anything to be aware of? I take it I need to run some sort of loop that just goes round in circles "x" amount of times based on F_CPU.

--- End quote ---
Yes:
1 code that has no real functionality has a large chance to becremoved if you set/enable the optimizer compiler options.
To prevent this read or increment some "volatile" declared variable in your loop.
Always check the resulting assembly after setting optimizer options, compikers can be very smart these days   ;)

2 Portability. your loop is tuned to your current cpu frequency.
Sometimes you want to lower the power consumption by lowering peripheral and/or cpu frequency and you run into problems. Or for portability in another project with other faster cpu the cpu clock differs. Anyway, The neat way of doing this is setting your cpu speed depending on some sort of #define value . You can use this value in your loop to determine the length to wait. Edit: see you already will use that  :-+

3 use an rtos or own os that does something usefull in the mean time your peripheral has to wait on the slow secondary hardware to become ready.

Simon:
Well with a 20.8 ns clock a 1┬Ás delay is 48 cycles. what can be done in 48 cycles? other delays are 450ns, 195ns and as low as 20ns.

Page 49 of the attached.

Navigation

[0] Message Index

[#] Next page

There was an error while thanking
Thanking...
Go to full version
Powered by SMFPacks Advanced Attachments Uploader Mod