Timeline for How to implement precise delay function in Keil c51 (for c8051) that waits exact amount of CPU clocks, the number of clocks ranges from 1 to 255
Current License: CC BY-SA 3.0
12 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
May 10, 2016 at 14:14 | comment | added | Cezar | I will try with another MCU unit, I mean the same model but just another physical unit, thanks for pointing that out. The project is to generate two pulses with precise, but independent width, that is changed based on the parameters passed through a communication channel to the MCU. Then the MCU collects the data of the system response that these pulses invoked and sends back through communication channel or stores locally some description of the systme to be used later. | |
May 10, 2016 at 13:23 | comment | added | Jasser | Have you also tried changing the MCU? Also what is your project by the way? Or you are doing it just to produce such delays? | |
May 10, 2016 at 13:22 | comment | added | Cezar | Hey Jasser, thank you very much for your response. I did it with a debugging kit, and I was able to take a look into registers, and so using a simple code the MCU does exactly the same trick every time with the djnz instruction. Thanks again for your input. | |
May 9, 2016 at 19:25 | comment | added | Jasser | 1. If you have a hardware kit then debug the code step by step and see the changes inside the registers. 2. Write a simple code in assembly which uses the same djnz instruction and find out whether it is behaving the same way. | |
May 9, 2016 at 14:30 | comment | added | Cezar | Hey Jasser, Thanks for a prompt response. So I sit next to the micro-controller and an oscilloscope, and what I see in clocks on the debugger, is what I get on the scope. Can't figure out how is that possible. It is nearly twice the amount of time silicon labs state on their datasheet. I am certainly doing something wrong here, and can't figure out what. | |
May 9, 2016 at 13:26 | comment | added | Jasser | The only thing which matters is the instructions and the time taken for it to execute and not where the code resides(The insructions delays take into account of the external residence of code if any). I would recommend you to try on hardware to check the amount of delays you are getting. I have not encountered such thing as of now on keil but maybe...it have something to do with the software... Try to check the delays on a oscilloscope! | |
May 9, 2016 at 11:21 | comment | added | Cezar | Hey Jasser, thank you for the followup. I tried the timer case, which is much more simple in terms of assembly code addition, but unfortunately for some reason I am getting a some strange results, the "JNB TF2H,$" instruction I use for timer overflow polling, takes 6-7 cycles to execute, while it is supposed to be 3/5 according to the data sheet. Can't find the reason for it to be so long. May be it is connected to the location of the code in the external memory? Any ideas? | |
May 9, 2016 at 6:16 | comment | added | Jasser | circuitstoday.com/delay-using-8051-timer This has a pretty looking code to generate a delay of 1ms (you can change the values inside the timer registers in your code to generate delays as per your requirement). Though the author has not considered the delay of commands in delay subroutine in assembly but you can also consider that to be 100% precise. | |
May 9, 2016 at 5:32 | comment | added | Cezar | Thank you for your comment. I have actually tried both in C, so I will probably try it in assembly. I pretty much see the way to implement it using NOPes, but not so sure how to go about it with timers in assembly, it is still requires a conditional decision, which takes plenty of cycles on it's own. | |
May 8, 2016 at 18:26 | history | edited | Jasser | CC BY-SA 3.0 |
added 8 characters in body
|
May 8, 2016 at 18:12 | history | edited | Jasser | CC BY-SA 3.0 |
More explanation
|
May 8, 2016 at 17:59 | history | answered | Jasser | CC BY-SA 3.0 |