We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
Hello,
I need to make a 0.25us period timer for my 1-wire bus. How can this be implemented best? I have my CPU (LPC2378) running at 48MHz. Can this be achieved best with the use of timers?
I then need an exact multiple of this timing (from 1 to about 100)
When I make a function to set my timer or do anything else, then I already need 0.366us for just calling the function.
Can anyone help me?
PS: 1 CPU clock takes: 1/48MHz = 20.833ns
First, back to my original question, do you really need the 250ns precision? If you don't then, surely, an assembler function must be the best way to do this?!
If you really do need the 250ns (which would only be if you're using overdrive speeds) then, I suppose, you'll have to pursue the NOPs...
As the Application Note 126 says, there are only ten different timings required in each set; Therefore, rather than try to debug a "clever" macro, why not just define a set of macros; eg,
#define DELAY_A (however many NOPs for the 'A' parameter in Table 2) #define DELAY_B (however many NOPs for the 'B' parameter in Table 2) etc...
If you want to pursue the "clever" macro, then start by examining the preprocessor output - to ensure that it is expanding correctly;
If that's OK, examine the generated code...