Quantcast
Channel: PIC24, what's wrong with my program?
Viewing all articles
Browse latest Browse all 18

Re: PIC24, what's wrong with my program? (kelvinu)

$
0
0

.include  "xc.inc"
                .bss
intcounter:     .space    2
                .text
.global __reset             
.global __T1Interrupt  
__reset:
    BCLR TRISB, #5
    BCLR TRISB, #6

;********************** ;setup timer 1 for interrupt
clr TMR1                 
mov #200,w12        
mov w12,intcounter 
mov #16000,w7     
mov W7,PR1        
bclr IFS0,#T1IF   
bset IEC0,#T1IE   
bset T1CON,#TON   
bclr IFS1,#CNIF
 
******************put loop here
loop:
    bset LATB, #5
    BRA loop
*****************************

__T1Interrupt:
push.s                
dec intcounter        
btss SR,#Z            
bra intcnotzero
btg LATB,#6          
mov #500,w0          
mov w0,intcounter   
intcnotzero:
bclr  IFS0, #T1IF     
pop.s                      
retfie                       
end

 
The subroutine __T1interrupt is only called when the interrupt happens.
 
I only posted the bits of code needed for the timer interupt. If you are programming just in assembler there is a load of chip setup stuff you need too.
 
When I get home i'll fishout my led flash prog and post a link.
 
8-)

Viewing all articles
Browse latest Browse all 18

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>