Unstable timer1/interrupt ..

Z

Zanor

Guest
Salut!

Je suis en cours de faire ma propre signe défilement de LED.Almoast tout fonctionne bien maintenant.J'ai mis en place timer1 (btw, PIC16F648A) à 1:8 prescale, et interrompre le débordement.Cela marche bien, mais parfois elle constate simplement que ce ne sera pas interrompre plus.

Les parchemins signe, mais tout à coup il s'arrête (sur une position aléatoire de la chaîne) et y reste.Je sais que le reste du programme PIC continue de s'exécuter parce que j'utilise 5 lignes et 1 seul est allumé à la fois.

J'ai aussi quelques tableaux dans mon code que je dois changer PCLATCH avant de sauter, il pourrait y avoir quelque chose avec ça?

S'il vous plaît aidez-moi!

Je poste mon code entier, It's kinda messy

<img src="http://www.edaboard.com/images/smiles/icon_razz.gif" alt="Razz" border="0" />J'ai essayé avec une autre puce thats so pas le foult ...

Code:__CONFIG 0x3F50

LISTE P = PIC16F648A

comprennent <P16F648A.INC>, Des variables et constantes

cblock 0x20; début de registres généraux

count; utilisés dans le retard de routine

count1, utilisé dans le retard de routine

nbval, utilisé dans le retard de routine

countb, utilisé dans le retard de routine

Sendme

CR; ligne en cours

LOOPC; Compteur de boucle

LOOPD; données Loop

STRING_I; String index

CHAR_I; Char index

C_FONT; police en cours

O_FONT; Offset

P_FONT; Page

temp

temp2

tmp_status, utilisé pour enregistrer INFO pendant interrompre

tmp_w, utilisé pour enregistrer INFO pendant interrompre

endcSCK equ 0x06; horloge série HC595

SI equ 0x05; données série HC595

RCK equ 0x07; HC595 horloge de sortie; Char et adresse de la chaîne

STRINGTABLE equ 0x500

FontTable equ 0xa00ORG 000H; une réinitialisation redirections programme à ce pointGOTO PRG_STARTORG 004h; une interruption redirige le programme ici

Movwf tmp_w

MOVFW ÉTAT

Movwf tmp_statusBCF PIR1, TMR1IFINCF CHAR_IMOVFW CHAR_I

SUBLW 0x06

Btfss STATUS, Z

Goto DoneMOVLW 0x01

Movwf CHAR_I

INCF STRING_Ifait

MOVFW tmp_status

Movwf STATUS

MOVFW tmp_w

Retfie
PRG_START

; Initialiser port

BSF STATUS, RP0; Bank1

MOVLW 0x02; RX Set (RB1) à l'entrée

Movwf TRISB

MOVLW 0x00

Movwf TRISA; Régler la vitesse à 4MHz

MOVLW 0x08

Movwf PCON; Initialiser USART

MOVLW 0x24; Emetteur: RS232

Movwf TXSTA;

BCF STATUS, RP0; Banque 0

MOVLW 0x90; Récepteur: RS232

Movwf RCSTA;; USART Baud rate ajuster

BSF STATUS, RP0; Bank1

MOVLW 0x19; Set Baud rate 9,6000 @ 4 MHz

Movwf SPBRG

BCF STATUS, RP0; Banque 0; Activer Timer1

MOVLW 0x31;

Movwf T1CON; Activer les interruptions

BSF INTCON, GIE; interruption globale permettant

BSF INTCON, PEIE; permettre interrrupt périphériques

BSF STATUS, RP0; Bank1

BSF PIE1, TMR1IE; permettre timer1 interrompre

BCF STATUS, RP0; Bank0
MOVLW 0x05; À partir de ligne du bas

Movwf CR, et vers le haut de travail.MOVLW 0x01, 1 - 5, 1 = Space

Movwf CHAR_I

MOVLW 0x00

Movwf STRING_IPRINCIPAL

MOVLW 0x08; auge Loop 8 bits

Movwf LOOPCBSF PORTB, SCK; Envoyer un début

BCF PORTB, SCK; impulsion d'horlogeClrf LOOPD; Start From ScratchMOVF STRING_I, F; voir si elle

BTFSC STATUS, Z; est le premier caractère

GOTO ICI, oui?
puis passez cette partieDECF STRING_I, FAPPEL get_char

Get_Font CALL; Get ligne de donnéesMovwf LOOPDINCF STRING_I, FICIAPPEL get_char

Get_Font CALL; Get ligne de donnéesMovwf temp2

RLF temp2, F

RLF temp2, F

RLF temp2, FMOVFW CHAR_I

Movwf tempLoop1

RLF temp2, F

RLF LOOPD, FTemp decfsz, F

GOTO Loop1BOUCLEBCF PORTB, SI; clear bit à envoyer

RLF LOOPD, F; Rotation ainsi nous obtenons le bit

, Nous voulons en Carrey

BTFSC STATUS, C; Avons-nous obtenu un 1?

BSF PORTB, SI; Oui, alors un bit à envoyerBSF PORTB, SCK, et l'envoyer

BCF PORTB, le SCKDecfsz LOOPC, F; compteur de boucle Diminution,

GOTO LOOP; sommes-nous fini de bouclage?MOVLW 0x00

Movwf PORTABSF PORTB, RCK, oui, puis afficher

BCF PORTB, RCK, la ligne a envoyéMOVFW CR; Déplacer la ligne actuelle à W

Tbl_row CALL; Get PORTA octet

Movwf PORTA; affichage de la ligne courante, Appel Delay1Decfsz CR, F

GOTO MAIN; Non dernière rangée, affichage suivant

MOVLW 0x05; dernière rangée, commencez dès

Movwf CR; rangée inférieure à nouveau.GOTO MAINget_char

MOVLW tbl_string HAUTE

Movwf PCLATHMOVFW STRING_I

APPEL tbl_stringMovwf temp

MOVLW HAUTE MAIN

Movwf PCLATHMOVFW tempRETOURget_Font

Movwf C_FONTMOVLW tbl_font élevé; Obtenir la page de démarrage

Movwf P_FONT; adresse.Movlw LOW tbl_font; Get offset

ADDWF C_FONT, W

BTFSC STATUS, C

INCF P_FONT, FADDWF C_FONT, W

BTFSC STATUS, C

INCF P_FONT, FADDWF C_FONT, W

BTFSC STATUS, C

INCF P_FONT, FADDWF C_FONT, W

BTFSC STATUS, C

INCF P_FONT, FADDWF C_FONT, W

BTFSC STATUS, C

INCF P_FONT, FADDWF CR, W

Movwf O_FONTMOVFW P_FONT

Movwf PCLATHMOVFW O_FONT

APPEL tbl_fontMovwf temp

MOVLW HAUTE MAIN

Movwf PCLATH

MOVFW tempRETOURtbl_row

addwf PCL, F

0x00 retlw; entrée factice .....
(PCL 0)

retlw 0x01; Rangée 1 (byte PORTA)

retlw 0x02; Row 2

retlw 0x04; ...

retlw 0x08

retlw 0x80tbl_data

addwf PCL, F

0x00 retlw; entrée factice .....
(PCL 0)

retlw 0xDB; Row 1 Données

retlw 0xAA; Row 2

retlw 0x81; ...

retlw 0x0F

retlw 0xFF; Delay routines (Ripped former quelque site web)Long_Delay

movlw d'50 '; 5 secondes de retard

appel Delay100W

retourDelay100W movwf count; retard W x 100 ms

d2 Delay100 appel; délai maximum 25,5 secondes

decfsz comte, f

goto d2

retourDelay255 movlw 0xff; retard 255 ms

goto d0

Delay100 movlw d'100 '; 100 ms de retard

goto d0

Delay50 movlw d'50 '; 50 ms de retard

goto d0

Delay20 movlw d'20 'de retard 20mS

goto d0

Delay10 movlw d'10 '; retard 10mS

goto d0

Delay1 movlw d'1 '; retard 1mS

goto d0

Delay5 movlw 0x05; délai 5.000 ms (4 Horloge MHz)

d0 movwf count1

d1 movlw 0xe7

movwf nbval

movlw 0x04

movwf countb

Delay_0 decfsz nbval, f

goto $ 2

decfsz countb, f

goto Delay_0decfsz count1, f

goto d1

retour
ORG STRINGTABLE

tbl_stringADDWF PCL, Fdt "Stian AAAABBBBCCCCAAAABBBBCCCC A A A"

dt "B B B B B"

dt "D D D D D"ORG FontTable

tbl_fontMovwf PCLdt 0x00, 0x00, 0x00, 0x00, 0x00, 0, Dummy entrée

dt 0x00, 0x00, 0x00, 0x00, 0x00

dt 0x00, 0x00, 0x00, 0x00, 0x00

dt 0x00, 0x00, 0x00, 0x00, 0x00

dt 0x00, 0x00, 0x00, 0x00, 0x00

dt 0x00, 0x00, 0x00, 0x00, 0x00

dt 0x00, 0x00, 0x00, 0x00, 0x00

dt 0x00, 0x00, 0x00, 0x00, 0x00

dt 0x00, 0x00, 0x00, 0x00, 0x00

dt 0x00, 0x00, 0x00, 0x00, 0x00

dt 0x00, 0x00, 0x00, 0x00, 0x00

dt 0x00, 0x00, 0x00, 0x00, 0x00

dt 0x00, 0x00, 0x00, 0x00, 0x00

dt 0x00, 0x00, 0x00, 0x00, 0x00

dt 0x00, 0x00, 0x00, 0x00, 0x00

dt 0x00, 0x00, 0x00, 0x00, 0x00

dt 0x00, 0x00, 0x00, 0x00, 0x00

dt 0x00, 0x00, 0x00, 0x00, 0x00

dt 0x00, 0x00, 0x00, 0x00, 0x00

dt 0x00, 0x00, 0x00, 0x00, 0x00

dt 0x00, 0x00, 0x00, 0x00, 0x00

dt 0x00, 0x00, 0x00, 0x00, 0x00

dt 0x00, 0x00, 0x00, 0x00, 0x00

dt 0x00, 0x00, 0x00, 0x00, 0x00

dt 0x00, 0x00, 0x00, 0x00, 0x00

dt 0x00, 0x00, 0x00, 0x00, 0x00

dt 0x00, 0x00, 0x00, 0x00, 0x00

dt 0x00, 0x00, 0x00, 0x00, 0x00

dt 0x00, 0x00, 0x00, 0x00, 0x00

 
Salut Zanor
Il semble que vous rencontrez des problèmes avec PCLATH.Si vous n'enregistrez pas PCLATH lors d'une toute GOTO ISR / CALL dans la recherche internationale mai vecteur à une adresse inattendue.

Essayez le démarrage suivant d'interruption et de fin d'assurer l'épargne contexte correct.
Code:

Intvec movwf W_TEMP; une économie contexte std

swapf STATUS, W; ....

movwf STATUS_TEMP; ....

movf PCLATH, W; ....

movwf PCLATH_TEMP; ....

clrf PCLATH; page0

clrf STATUS; Bank0

;

;

; Routine d'interruption ici ******** ************

;

;

ISRdone

movf PCLATH_TEMP, W; contexte std restaurer

movwf PCLATH; ....

swapf STATUS_TEMP, W; ....

movwf STATUS; ....

swapf W_TEMP, F; ....

swapf W_TEMP, W; ....

retfie

;
 
polymathe a écrit:

Salut Zanor

Essayez le démarrage suivant d'interruption et de fin d'assurer l'épargne contexte correct.Code:

Intvec movwf W_TEMP; une économie contexte std

swapf STATUS, W; ....

movwf STATUS_TEMP; ....

movf PCLATH, W; ....

movwf PCLATH_TEMP; ....

clrf PCLATH; page0

clrf STATUS; Bank0

;

;

; Routine d'interruption ici ******** ************

;

;

ISRdone

movf PCLATH_TEMP, W; contexte std restaurer

movwf PCLATH; ....

swapf STATUS_TEMP, W; ....

movwf STATUS; ....

swapf W_TEMP, F; ....

swapf W_TEMP, W; ....

retfie

;
 

Welcome to EDABoard.com

Sponsor

Back
Top