Hello all!!
An update and help request on my program:
Code:
define loader_used 1
define osc 20
;---Defining Variables---
wsave var byte $70 system
ssave var byte bank0 system
psave var byte bank0 system
count0 var byte bank0 system
count1 var byte bank0 system
count2 var byte bank0 system
count3 var byte bank0 system
count4 var byte bank0 system
count5 var byte bank0 system
hulp0 var byte bank0 system
hulp1 var byte bank0 system
hulp2 var byte bank0 system
whulp var byte bank0 system
pclhulp var byte bank0 system
sthulp var byte bank0 system
;---Zeroing registers---
count0 = 0
count1 = 0
count2 = 0
count3 = 0
count4 = 0
count5 = 0
hulp0 = 0
hulp1 = 0
hulp2 = 0
whulp = 0
pclhulp = 0
sthulp = 0
STATUS.0 = 0
Goto main ;Skip interrupt routine
define INTHAND int
DISABLE DEBUG
asm
;---Save W, STATUS and PCLATH---
int movwf whulp
swapf STATUS, W
clrf STATUS
movwf sthulp
movf PCLATH, W
movwf pclhulp
;---Clock program---
incf count0, F
movwf count0
call check
movf count0, W
btfss STATUS,0
goto eindafwerking
incf count1, F
movwf count1
call check
movf count1, W
btfss STATUS,0
goto eindafwerking
incf count2, F
movwf count2
call check
movf count2, W
btfss STATUS,0
goto eindafwerking
incf count3, F
movwf count3
call check
movf count3, W
btfss STATUS,0
goto eindafwerking
incf count4, F
movwf count4
call check
movf count4, W
btfss STATUS,0
goto eindafwerking
incf count5, F
movwf count5
call check
movf count5, W
btfss STATUS,0
goto eindafwerking
;---Restore W, STATUS and PCLATH---
eindafwerking movf pclhulp, W
movwf PCLATH
swapf sthulp, W
movwf STATUS
swapf whulp, F
swapf whulp, W
bcf intcon,2
retfie
;---Check function for counts to be 99h maximum (NOT USED YET)---
check return
ENDASM
ENABLE DEBUG
main:
INTCON = %10100000 ;GIE enabled, T0IE enabled
OPTION_REG = %00000111
goto loop
loop: goto loop ;Wait here for interrupt
The program before (with the LED) was to time it on 1 millisecond, the final program (which isn't this one ofcourse
) is for measurement purposes.
Test step 2:
What I try to do here is to make a counter, that increments count0 when the timer overflows, then when count0 is full, it increments count1 etc etc. Atleast... it should do that....
The things i tried to make it work:
- Reset the C flag of STATUS, only this made only count0 to run.
- Switched , W with , F and vice versa (example: STATUS, W becomes STATUS, F)
A colleague told me to make some own save location (pclhulp, whulp and sthulp). I'm not sure if this is okay...
If someone could help me out again, I will be very gratefull (again!!). 
Cheers,
William
(Excuse me for the dutch labeling, it shouldn't be be much of a problem i guess
)
/EDIT:
Allrightey I fixed the problem myself! Yay ^^!
Code:
define loader_used 1
define osc 20
;---Defining Variables---
wsave var byte $70 system
ssave var byte bank0 system
psave var byte bank0 system
count0 var byte bank0 system
count1 var byte bank0 system
count2 var byte bank0 system
count3 var byte bank0 system
count4 var byte bank0 system
count5 var byte bank0 system
hulp0 var byte bank0 system
hulp1 var byte bank0 system
hulp2 var byte bank0 system
whulp var byte bank0 system
pclhulp var byte bank0 system
sthulp var byte bank0 system
;---Zeroing registers---
count0 = 0
count1 = 0
count2 = 0
count3 = 0
count4 = 0
count5 = 0
hulp0 = 0
hulp1 = 0
hulp2 = 0
whulp = 0
pclhulp = 0
sthulp = 0
STATUS.2 = 0
Goto main ;Skip interrupt routine
define INTHAND int
DISABLE DEBUG
asm
;---Save W, STATUS and PCLATH---
int movwf whulp
swapf STATUS, W
clrf STATUS
movwf sthulp
movf PCLATH, W
movwf pclhulp
;---Clock program---
incf count0, F
movf count0, W
call check
movwf count0
btfss STATUS,2
goto eindafwerking
bcf STATUS,2
incf count1, F
movf count1, W
call check
movwf count1
btfss STATUS,2
goto eindafwerking
bcf STATUS,2
incf count2, F
movf count2, W
call check
movwf count2
btfss STATUS,2
goto eindafwerking
bcf STATUS,2
incf count3, F
movf count3, W
call check
movwf count3
btfss STATUS,2
goto eindafwerking
bcf STATUS,2
incf count4, F
movf count4, W
call check
movwf count4
btfss STATUS,2
goto eindafwerking
bcf STATUS,2
incf count5, F
movf count5, W
call check
movwf count5
bcf STATUS,2
goto eindafwerking
;---Restore W, STATUS and PCLATH---
eindafwerking movf pclhulp, W
movwf PCLATH
swapf sthulp, W
movwf STATUS
swapf whulp, F
swapf whulp, W
bcf intcon,2
retfie
;---Check function for counts to be 99h maximum (NOT USED YET)---
check return
ENDASM
ENABLE DEBUG
main:
INTCON = %10100000 ;GIE enabled, T0IE enabled
OPTION_REG = %00000111
goto loop
loop: goto loop ;Wait here for interrupt
What I did wrong:
- I switched the movf and the movwf instructions!
- Checked the wrong bit, it checked the carry flag (Status.0) instead of the Zero flag (Status.2)
I feel so noobish >)
Bookmarks