2011-08-09 14 views
1
#include<p18f452.inc> 
TIMER set 0x00 
COUNT1 set 0x01 
COUNT2 set 0x02 
    org 0x00 
    goto start 
    org 0x08 
    goto int_1 
    goto int_2 
    org 0x18 
    retfie 

start movlw 0xFF 
    movwf TRISB,A 
    clrf TRISD,A 
    clrf TRISC,A 
    movlw 0x3F 
    movwf PORTD,A 
    movlw 0x3F 
    movwf PORTC,A 

set_time BSF RCON,7,A ;INTERUPT 
    BSF INTCON,7,A 
    BSF INTCON,4,A 
    BCF INTCON,1,A 
    bsf INTCON3,4,A 
    bcf INTCON3,0,A 
    movlw D'60' 
    movwf TIMER,A 
    call TIME_1 
    goto set_time 


TIME_1 movlw 0x85 
      movwf T0CON,A 
loopt movlw 0x3D 
    movwf TMR0H,A 
    movlw 0x09 
    movwf TMR0L,A 
    bcf INTCON,2,A 
wait btfss INTCON,2,A 
    bra wait 
    decfsz TIMER,F,A 
    bra loopt 
    return 

int_1 btfss INTCON,1,A 
    goto eint_1 
    incf COUNT1,F,A 
    btfsc COUNT1,3,A 
    goto num_9 
    btfsc COUNT1,2,A 
    goto num_7654 
    btfsc COUNT1,1,A 
    goto num3_2 
    btfsc COUNT1,0,A 
    goto num1 
eint_1 retfie 

int_2 btfss INTCON3,0,A 
    goto eint_2 
    incf COUNT2,F,A 
    btfsc COUNT2,3,A 
    goto num_9_2 
    btfsc COUNT2,2,A 
    goto num_7654_2 
    btfsc COUNT2,1,A 
    goto num3_2_2 
    btfsc COUNT2,0,A 
    goto num1_2 
eint_2 retfie 


num_9 btfsc COUNT1,0,A 
    goto nom9 
    goto nom8 
num_7654 btfss COUNT1,1,A 
    goto nom4_5 
    goto nom6_7 
num3_2 btfss COUNT1,0,A 
    goto nom2 
    goto nom3 
num1 movlw 0x06 
    movwf PORTD,A 
    goto eint_1 


nom9 movlw 0x67 
    movwf PORTD,A 
    goto eint_1 
nom8 movlw 0x7F 
    movwf PORTD,A 
    goto eint_1 
nom6_7 btfss COUNT1,0,A 
    goto nom6 
    goto nom7 
nom6 movlw 0x7D 
    movwf PORTD,A 
    goto eint_1 
nom7 movlw 0x07 
    movwf PORTD,A 
    goto eint_1 
nom4_5 btfss COUNT1,0,A 
    goto nom4 
    goto nom5 
nom4 movlw 0x66 
    movwf PORTD,A 
    goto eint_1 
nom5 movlw 0x6D 
    movwf PORTD,A 
    goto eint_1 
nom2 movlw 0x5B 
    movwf PORTD,A 
    goto eint_1 
nom3 movlw 0x4F 
    movwf PORTD,A 
    goto eint_1 


num_9_2 btfsc COUNT2,0,A 
    goto nom9_2 
    goto nom8_2 
num_7654_2 btfss COUNT2,1,A 
    goto nom4_5_2 
    goto nom6_7_2 
num3_2_2 btfss COUNT2,0,A 
    goto nom2_2 
    goto nom3_2 
num1_2 movlw 0x06 
    movwf PORTC,A 
    goto eint_2 


nom9_2 movlw 0x67 
    movwf PORTC,A 
    goto eint_2 
nom8_2 movlw 0x7F 
    movwf PORTC,A 
    goto eint_2 
nom6_7_2 btfss COUNT2,0,A 
    goto nom6_2 
    goto nom7_2 
nom6_2 movlw 0x7D 
    movwf PORTC,A 
    goto eint_2 
nom7_2 movlw 0x07 
    movwf PORTC,A 
    goto eint_2 
nom4_5_2 btfss COUNT2,0,A 
    goto nom4_2 
    goto nom5_2 
nom4_2 movlw 0x66 
    movwf PORTC,A 
    goto eint_2 
nom5_2 movlw 0x6D 
    movwf PORTC,A 
    goto eint_2 
nom2_2 movlw 0x5B 
    movwf PORTC,A 
    goto eint_2 
nom3_2 movlw 0x4F 
    movwf PORTC,A 
    goto eint_2 
    end 

実際にこのコーディングは人のカウンターと7セグメントで表示されます。しかし、問題は、このプログラムを実行するとき、それは関数ではなく、私はどこに問題があるのか​​わかりません。私はそれを正しくしていたと思う。pic18で割り込みサービスルーチンを行う方法

+0

をあなたが言及していないだけで書くよりも、PIC18の下で中断書き込むに

あなたが直面している特定の問題について?割り込みに入るのですか? – Kamath

+0

P18にC18コンパイラがサポートされているので、Cに切り替えることができます。 – Kamath

答えて

0

代わりに絶対コードモデル私はリロケータブルコードモデルを使用するために真に助言する。

のサンプルコード:コードをチェックして報告するシミュレータで構築されたMPLABを使用するよりも

#include<p18f452.inc> 
_Shared  udata_acs  0  ;Shared memory file registers 
IntReg1  res    1 
IntReg2  res    1 
;... declare shared variables 

_UpperBank0 udata   060h  ;Banked file memory registers 
RegA   res    1 
;...declare application variables 

_Bank1   udata   0100h ;Banked file memory registers 
N    res    1 
;...declare application variables 

;CODE 
_ResetCPU  code  0 
       movlw  b'01100000' ;init MCPU file registers 
       movwf  ;... 
       goto  ContinueInitCpu 

_Interrupt  code  8 
       movlb  high _Bank1 
; 
;interrupt code 
; 
       retfie  ;return from interrupt 
; 
ContinueInitCpu 
       movlw  b'01100000' ;init MCPU file registers 
       movwf  ;... 
;... 
; 
; Application code 
; 

...

関連する問題