Hi Bart,
The calibration code should only take about 5-6us to run. If that's a problem you should deal with it using a pullup resistor or something similar. However, i must say that i'm a bit confused why your code will not run the way you've written it. It may have something to do with PCLATH, i'm not sure how PBC handles this. It shouldn't be a problem if the ASM code is at the very top of your program(as you've already realized). My advice .... don't mess with it, leave it at the top.
The code you've written will ouput LOW level on pin 0 for a few us. First you make the pin an output with "poke $85,%00000100", after that you tell the pin to be high with "high 0". In the short time between theese commands, pin 0 will be driven low. The solution is to set the pin to your desired value BEFORE you make it an output.
I recommend you to add a pullup to pin 0 and write the code like this ...........
My somewhat fading memory tells me that it's essential that your asmcode is "tabbed". Everything located on the first position on a line will be interpreted(by the assembler) as a label, not code. Beware that i might be wrong about this.Code:asm bsf RP0 call 03ffh movwf OSCCAL bcf RP0 endasm poke $19,%00000111 poke $05,%00000001 'Make sure bit0 starts high poke $85,%00000100 ' Rest of your code
/Ingvar




Bookmarks