Hi forum! I need a delay in a programm but _nop_() seems not to work. Thus I wrote the following code in the main function where x is an IO pin: while(1) { x = 1; _nop_(); x = 0; _nop_(); } Only the second _nop_() causes a delay but not the first one. µVsioin2 is used. Can anybody help me? Thanks Fabian
I'm really sorry guys, but I still don't understand what I'm doing wrong. Because you insist on programming the chip without taking the time to understand the chip. If you have no idea of the chips architecture, how in the world do you expect to be able to calculate a delay. C is wonderful, but (especially in the embedded world) it does not release you from understanding what you are working with. Erik
The output is low for 3 instructions and high for 2. This is why the high time and low time are not equal.
?C0003: BSET Testpin ; Output Low NOP ; Output High BCLR Testpin ; Output High NOP ; Output Low JMP cc_UC,?C0003 ; Output Low
GOT IT! Thanks everybody for your help. @Walter: This is exactly the information I needed. @Erik: I wish I had the time to get to know the chip better but unfortunately I don't. Fabian
This is exactly the information I needed. Good, just remember that the things that Mike spoke of will definitely affect timing. If you need to get down to that level of detail, you will have to take those things into account.
I wish I had the time to get to know the chip better but unfortunately I don't. Good luck, you will need it. Erik
"I wish I had the time to get to know the chip better but unfortunately I don't." Doesn't the very fact that you needed to start this thread (plus the fact that it took so long for the penny to drop) rather suggest that you really do need that understanding...?