First CAN Transmission ok, but i can't send a second message ATMega16M1 asm

1 post / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Sorry for my bad english and the google translation.

I have the problem that after sending the first message, I can not send any more. I have sometimes attached my code in excerpts, maybe someone can tell me what I forget to do to start a new transfer.

Means of the subprograms "init_CAN_Identifier_an" or "init_CAN_Identifier_off" I select the CAN ID / message and then go to "Send" to send the message, which also works wonderfully. But what comes next and especially in what order to be able to start a new transmission.

 

Please help me

;PCI_init:
;ldi temp, (1<<PCINT7)| (1<<PCINT6)| (1<<PCINT5)| (1<<PCINT4)| (1<<PCINT3)| (1<<PCINT2)| (1<<PCINT1)| (1<<PCINT0)
;sts PCMSK0, temp ;Interrupt Mode aktivieren

Int_init:
;ldi temp, (0<<ISC31)| (0<<ISC30)|(0<<ISC21)|(0<<ISC20)|(0<<ISC11)|(0<<ISC10)|(0<<ISC01)|(0<<ISC00)
;sts EICRA, temp ;External Interrupt Control Register A
;ldi temp, (0<<INT3)| (0<<INT2)| (0<<INT1)| (0<<INT0)
;sts EIMSK, temp ;External Interrupt Mask Register
;ldi temp, (0<<PCIE3)| (0<<PCIE2)| (0<<PCIE1)| (1<<PCIE0)
;sts PCICR, temp ;Pin Change Interrupt Control Register

;***********************************************************************************************
CAN_init:
ldi temp, (0<<ABRQ)|(0<<OVRQ)|(0<<TTC)|(0<<SYNTTC)|(0<<LISTEN)|(0<<TEST)|(0<<ENASTB)|(1<<SWRES)
sts CANGCON, temp ; CAN General Control Register,   software reset

BAUDRATE_init:
ldi temp, (0<<BRP5)|(0<<BRP4)|(1<<BRP3)|(0<<BRP2)|(0<<BRP1) |(1<<BRP0)
sts CANBT1, temp ; set baud rate to 16 kbps bei Stystem Clock 8 Mhz
ldi temp, (1<<PRS2)|(1<<PRS1)|(1<<PRS0)
sts CANBT2, temp
ldi temp, (1<<PHS22)|(1<<PHS21)|(1<<PHS20)|(1<<PHS12)|(1<<PHS11)|(1<<PHS10)|(1<<SMP)
sts CANBT3,temp

;Interrupt für ACK Error Freigeben
ldi temp,(0<<ENIT)|(0<<ENBOFF)|(0<<ENRX)|(0<<ENTX)|(0<<ENERR)|(0<<ENBX)|(0<<ENERG)|(0<<ENOVRT)
sts CANGIE, temp

;enable CAN Status Interrupt
ldi temp, (0<<SIT5)|(0<<SIT4)|(0<<SIT3)|(0<<SIT2)|(0<<SIT1)|(0<<SIT0)
sts CANSIT2, temp

;CAN timer Prescaler
ldi temp,(0<<TPRSC7)|(0<<TPRSC6)|(0<<TPRSC5)|(0<<TPRSC4)|(0<<TPRSC3)|(0<<TPRSC2)|(0<<TPRSC1)|(0<<TPRSC0)
sts CANTCON,temp

;CAN Highest Priority MOb Register
;ldi temp,(0<<HPMOB3)|(0<<HPMOB2)|(0<<HPMOB1)|(0<<HPMOB0)|(0<<CGP3)|(0<<CGP2)|(0<<CGP1)|(0<<CGP0)
;sts CANHPMOB,temp

;init_CAN_Identifier_Maske: ;Filter deaktivieren, alle eingehenden Nachrichten werden verarbeitet
;ldi temp, 0
;sts CANIDM1, temp
;sts CANIDM2, temp
;sts CANIDM3, temp
;sts CANIDM4, temp

ldi temp, (0<<MOBNB3)|(0<<MOBNB2)|(0<<MOBNB1)|(0<<MOBNB0)|(0<<AINC)|(0<<INDX2)|(0<<INDX1)|(0<<INDX0)
sts CANPAGE, temp ; select MOb0

ldi temp,(0<<ENMOB5)|(0<<ENMOB4)|(0<<ENMOB3)|(0<<ENMOB2)|(0<<ENMOB1)|(0<<ENMOB0)
sts CANEN1, temp ; enable MOB

ldi temp, 0b00000000
sts CANEN2, temp ; enable MOB

ldi temp,(0<<CONMOB1)|(0<<CONMOB0)|(0<<RPLV)|(0<<IDE)|(0<<DLC3)|(0<<DLC2)|(0<<DLC1)|(1<<DLC0)
sts CANCDMOB, temp ; disable, CAN 11bit identifier, 8bit data lenght muss vor CANGCON übermittelt werden

ldi temp, (0<<ABRQ)|(0<<OVRQ)|(0<<TTC)|(0<<SYNTTC)|(0<<LISTEN)|(0<<TEST)|(1<<ENASTB)|(0<<SWRES)
sts CANGCON, temp ; CAN General Control Register,   software reset

Ready_enable:
lds temp, CANGSTA ;
sbrs temp, ENFG ;CAN enable
rjmp Ready_enable ;springt raus, wenn fertig

Senden:
ldi temp,(0<<ENMOB5)|(0<<ENMOB4)|(0<<ENMOB3)|(0<<ENMOB2)|(0<<ENMOB1)|(0<<ENMOB0)
sts CANEN1, temp ; enable MOB
ldi temp, 0b00000000
sts CANEN2, temp ; enable MOB
ldi temp,(0<<CONMOB1)|(0<<CONMOB0)|(0<<RPLV)|(0<<IDE)|(0<<DLC3)|(0<<DLC2)|(0<<DLC1)|(1<<DLC0)
sts CANCDMOB, temp ; TX Mode disable, CAN 11bit identifier, 8bit data lenght muss vor CANGCON übermittelt werden
ldi temp,(0<<CONMOB1)|(1<<CONMOB0)|(0<<RPLV)|(0<<IDE)|(0<<DLC3)|(0<<DLC2)|(0<<DLC1)|(1<<DLC0)
sts CANCDMOB, temp ; TX Mode enable, CAN 11bit identifier, 8bit data lenght muss vor CANGCON übermittelt werden

OK_TX: ;Prüfe ob Übertragung beendet
lds temp, CANSTMOB
sbrs temp, TXOK ;Transmission ok?
rjmp OK_TX ;springt raus, wenn fertig
;rcall CAN_on
ldi temp,(0<<CONMOB1)|(0<<CONMOB0)|(0<<RPLV)|(0<<IDE)|(0<<DLC3)|(0<<DLC2)|(0<<DLC1)|(1<<DLC0)
sts CANCDMOB, temp ; TX Mode disable, CAN 11bit identifier, 8bit data lenght muss vor CANGCON übermittelt werden
ldi temp,(0<<ENMOB5)|(0<<ENMOB4)|(0<<ENMOB3)|(0<<ENMOB2)|(0<<ENMOB1)|(0<<ENMOB0)
sts CANEN1, temp ; disable MOB
lds temp, CANSTMOB
clr temp
sts CANSTMOB, temp
ldi Zaehler1,0
ldi temp, (0<<ABRQ)|(0<<OVRQ)|(0<<TTC)|(0<<SYNTTC)|(0<<LISTEN)|(0<<TEST)|(1<<ENASTB)|(1<<SWRES)
sts CANGCON, temp ; CAN abort

Ready_TX: ;Prüfe ob Sender bereit oder noch sendet
lds temp, CANGSTA
sbrc temp, TXBSY ;Transmission busy?
rjmp Ready_TX ;springt raus, wenn fertig

init_CAN_Identifier_an:
ldi temp, 0b01010001 ;higher Bits = OG, Bad, Licht 1
sts CANIDT1, temp
ldi temp, 0b00100000 ;lower Bits
sts CANIDT2, temp ;00000000 =
ldi temp, 0b00000010 ;00000001 = an; 00000000 = aus ; 00000010 = wechseln
sts CANMSG, temp
ldi temp,1
sts status4, temp
ldi temp, 0b10000000 ;LED PortB7 an
out portd, temp
rjmp senden

init_CAN_Identifier_aus:
ldi temp, 0b01010001 ;higher Bits
sts CANIDT1, temp
ldi temp, 0b00100000 ;lower Bits
sts CANIDT2, temp ;00000000 =
ldi temp, 0b00000010 ;00000001 = an; 00000000 = aus ; 00000010 = wechseln
sts CANMSG, temp
ldi temp, 0
sts status4, temp
ldi temp, 0b00000000 ;LED PortB7 aus
out PortD, temp
rjmp senden

CAN-reset:
lds temp, CANSTMOB
clr temp
sts CANSTMOB, temp

 

Last Edited: Sat. Apr 7, 2018 - 09:53 AM