Hello all,
I've been struggling with a, for a not-picbasic-newbie (which I am!
), simple problem. I'm trying to let a LED blink on the overflow rate of timer0. Unfortunately I wasn't very succesfull.
When I run the following code (I know the LED won't blink with this, but that's step 2)
Code:
define loader_used 1
define osc 20
led var portc.1 ;LED is connected on PortC.1
wsave var byte $20 system
ssave var byte bank0 system
psave var byte bank0 system
Goto main
define INTHAND tmroverflow
asm
tmroverflow movwf wsave
swapf STATUS, W
clrf STATUS
movwf ssave ;Interrupt
movf PCLATH, W ;Routine
movwf psave ;with Save function
bsf _led ;Put on LED
movf psave, W
movwf PCLATH
swapf ssave, W
movwf STATUS
swapf wsave, F
swapf wsave, W
bcf intcon,2 ;Clear Interrupt Flag
retfie
ENDASM
main:
INTCON = %10100000 ;GIE enabled, T0IE enabled
OPTION_REG = %00000101 ;Prescaler on TMR0 rate 1:32
goto loop
loop:
goto loop ;Wait here for interrupt
When I run it in debug mode, the compiler goes insane and gives me mismatched address errors after the timer didn't respond for some time (the watchdog timer is off, so it isn't him who's complaining
)
I think that my mistake is in the INTCON and/or the OPTION_REG, but experimenting with this values didn't helped me further neither.
The "save" function is O.K asfar as I can see, since it's straight out of the manual!! 
All it need to do for step 1 is to light the LED...
So if someone sees the problem right away, and I'm sure there will be many, please help this desperate newbie! I will be very gratefull!
Cheers,
William
Bookmarks