Forum: Mikrocontroller und Digitale Elektronik CAN: 29-Bit mode geht nicht


von Dummer Coder (Gast)


Lesenswert?

Hab hiern SAM3X8E mit nem abegeänderten Example von Atmel der an nem 
Simulator läuft. Im 11-Bit Standard Mode funktioniert der Datenverkehr. 
Auf dem Oszi sehe ich jedoch, daß im 29-Bit Extended-ID Mode der 
Simulator auf eine Anfrage kein Paket zurücksendet.

Bis jetzt habe ich im Datenblatt nur gefunden, daß man das Bit MIDE für 
die ID-Version (Standard-ID CAN Vers. A 11-Bit/Extended-ID CAN Vers. B 
29-Bit) umschalten muß.

Hab ich noch etwas vergessen? Oder mache ich grundsätzlich was faltsch?

1
void getECUData(can_mb_conf_t *p_sc_mailbox_rx, can_mb_conf_t *p_sc_mailbox_tx) {    
2
    
3
    /* Note: The CAN transceiver should be configured before initializing the CAN module. */
4
    can_reset_all_mailbox(CAN0);    
5
    reset_mailbox_conf(p_sc_mailbox_rx);
6
7
    /* Init CAN0 Mailbox 1 to Reception Mailbox. */
8
    p_sc_mailbox_rx->ul_mb_idx = TEST1_CAN_COMM_MB_IDX + 1;  //mailbox 1
9
    p_sc_mailbox_rx->uc_obj_type = CAN_MB_RX_MODE;
10
    p_sc_mailbox_rx->ul_id_msk = CAN_MAM_MIDvA_Msk | CAN_MAM_MIDvB_Msk; //CAN 2.0A + B    
11
    if (!eepromData[EEPROM_CAN_11_29_BIT_ID]){
12
      p_sc_mailbox_rx->ul_id = CAN_MID_MIDvA(0x7E8);  //get 7E8 from engine control module
13
      p_sc_mailbox_rx->uc_id_ver = 0; // 0/1: standard/extended frame  
14
    }
15
    else  {
16
      p_sc_mailbox_rx->ul_id = CAN_MID_MIDvB(0x7E8);  //get 7E8 from engine control module    
17
      p_sc_mailbox_rx->uc_id_ver = 1; // 0/1: standard/extended frame
18
    }  
19
    can_mailbox_init(CAN0, p_sc_mailbox_rx);
20
    
21
22
// RELEVANTE SENDEROUTINE AB HIER --------------------------------
23
24
25
    /* Init CAN0 Mailbox 0 to Transmit Mailbox. */
26
    p_sc_mailbox_tx->ul_mb_idx = TEST1_CAN_COMM_MB_IDX;    //mailbox 0
27
    p_sc_mailbox_tx->uc_obj_type = CAN_MB_TX_MODE;
28
    p_sc_mailbox_tx->uc_tx_prio = TEST1_CAN0_TX_PRIO;
29
    p_sc_mailbox_tx->ul_id_msk = CAN_MAM_MIDvA_Msk | CAN_MAM_MIDvB_Msk; //CAN 2.0A + B
30
    can_mailbox_init(CAN0, p_sc_mailbox_tx);
31
32
    /* Write transmit information into mailbox. */
33
    if (!eepromData[EEPROM_CAN_11_29_BIT_ID]){
34
      p_sc_mailbox_tx->ul_id = CAN_MID_MIDvA(0x7DF);  // engine control module
35
       p_sc_mailbox_tx->uc_id_ver = 0; // 0/1: standard/extended frame
36
    }
37
    else {
38
      p_sc_mailbox_tx->ul_id = CAN_MID_MIDvB(0x7DF);  // engine control module
39
       p_sc_mailbox_tx->uc_id_ver = 1; // 0/1: standard/extended frame
40
      printf ("DEBUG: in getECUData(); 29bit frame mode\r\n");       
41
    }
42
    //p_sc_mailbox_tx->ul_datal = ...; set by caller
43
    //p_sc_mailbox_tx->ul_datah = ...;
44
    p_sc_mailbox_tx->uc_length = MAX_CAN_FRAME_DATA_LEN; // 8bytes
45
    can_mailbox_write(CAN0, p_sc_mailbox_tx);
46
    can_enable_interrupt(CAN0, CAN_IER_MB1);
47
    
48
    /* Send out the information in the mailbox. */
49
    can_global_send_transfer_cmd(CAN0, CAN_TCR_MB0);
50
51
52
// RELEVANTE SENDEROUTINE BIS HIER --------------------------------
53
54
55
}

Bitte melde dich an um einen Beitrag zu schreiben. Anmeldung ist kostenlos und dauert nur eine Minute.
Bestehender Account
Schon ein Account bei Google/GoogleMail? Keine Anmeldung erforderlich!
Mit Google-Account einloggen
Noch kein Account? Hier anmelden.