I was reading data sheet and want to learn Timer0 in assembly so, i have confusion as the interrupt addr is 0x04 so, how to set for external clock...here is the code which need help.
The aim of code is to change the output high when timer is overflow..
Code:
LIST p=16f72
#include "p16f72.inc"
__config b'00000000011111'
org 0x00
bsf STATUS,RP0 ; bank 1
movlw b'01000000' ;internal inst cycle showing error at option?
; movwf OPTION
bcf STATUS,RP0; bank 0
movlw b'10100100'
movwf INTCON; enable interrupt
bsf STATUS,RP0 ; bank 1
movlw 0x00
movwf TRISB; output direction
bcf STATUS,RP0
loop
movlw 0x00
movwf PORTB
goto loop
org 0x04
goto loop
retlw 0x00
end
loop
movlw 0x00
movwf PORTB
goto loop
org 0x04
goto loop ; <----- No No No and a big NO
retlw 0x00 ; should be retfie
Look at the above code...
You have the interrupt at 0x04.... When your timer fires the code in the interrupt is run... The micro already takes care of the return automatically ( the reason for the command RETFIE... return from interrupt and enable )
So if you place a goto in the interrupt to outside the interrupt... the intrrrupt never ends and you get a stack underflow..
Its part of a program code definition header, in what context did you use/find it. E
; DFlag
dmx_recieve equ 0 ; Dmx recieve display
dmx_msb equ 1 ; Displaying DMX MSB
dmx_csb equ 2 ; Displaying DMX CSB
dmx_lsb equ 3 ; Displaying DMX LSB
preset_intro equ 4 ; Displaying Preset Intro
At what frequency are you running? Have you confirmed it? When you say the led's aren't blinking, have you looked at a port pin with your oscilloscope?
Also you have RC oscillator selected.... Is this what you want.... Simulators usually ignore OSC settings that's why they work on sim but not for real.
Please post a schematic. Do you have MCLR tied high? If in fact you are anywhere near 20 MHz, or even 1 MHz, it is unlikely the short delay* you have inserted will be visible as a flashing LED. Did you test with an oscilloscope as I asked? Did you change the delay to 0xFF?
John
Edit: 0x255 is read as 0x55 or just decimal 85 counts.