Hi guys. I have prtty much completed an embedded design project I am working on, a spinning LED persistance of vision display. Every aspect of the program works fine apart from the delay routine.
For interests sake, here is my program (it's heavily annotated):
C code - 270 lines - codepad
Basically, all I need to do is create a delay routine which takes in a 0-65535 number, and delays for that many microseconds. So a value of 43 passed into the routine creates a delay for 43us. I'm using a PIC16F887.
The PIC is set at 4MHz, so each instruction takes 1us. I suspect there is going to have to be a fixed, small delay for the routine to start so that shouldnt be a problem so long as its not too long. I suspect I am going to be using assembly in the C code, I have a vague idea of how this might work. DECFSZ decrements the variable modified by the C program and does so until the delay routine is up.
Does anyone know how to protect 16 bits of memory from being overwritten by anything else, and place a variable in this specific location? This way, I can easily address it in assembly.
Thanks for your help
For interests sake, here is my program (it's heavily annotated):
C code - 270 lines - codepad
Basically, all I need to do is create a delay routine which takes in a 0-65535 number, and delays for that many microseconds. So a value of 43 passed into the routine creates a delay for 43us. I'm using a PIC16F887.
The PIC is set at 4MHz, so each instruction takes 1us. I suspect there is going to have to be a fixed, small delay for the routine to start so that shouldnt be a problem so long as its not too long. I suspect I am going to be using assembly in the C code, I have a vague idea of how this might work. DECFSZ decrements the variable modified by the C program and does so until the delay routine is up.
Does anyone know how to protect 16 bits of memory from being overwritten by anything else, and place a variable in this specific location? This way, I can easily address it in assembly.
Thanks for your help