CAN Driver for MPC5777M

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

CAN Driver for MPC5777M

2,950件の閲覧回数
yalamandadosaky
Contributor V

Hi All, Can any one help how to write a CAN driver  for the MPC 5777M or similar kind of Microcontroller

Martin Kovar

ラベル(1)
タグ(3)
14 返答(返信)

1,716件の閲覧回数
yalamandadosaky
Contributor V

Hi Petr Stancik, I am unable to transmit Data with M_CAN_2 as the TXBAR register is not taking 1 to start trasmission. I tried ,but I did n't get any breakthrough. Reception of CAN messages is working.

0 件の賞賛

1,716件の閲覧回数
martin_kovar
NXP Employee
NXP Employee

Hi,

CAN driver is very general term. There are many CAN stacks with different functionality. I can provide you simple MCAN example, which is created for MPC5777C, but it is also possible to use it with MPC5777M. You should check GPIO settings and clocking, but the module is the same. Please look at the following URL:

Example MPC5777C MCAN simpleTXRX GHS616 

https://community.nxp.com/docs/DOC-332736 

Regards,

Martin

1,716件の閲覧回数
yalamandadosaky
Contributor V

Hi Martin Kovar ,Thank you, I checked the sample code given for MPC 5777C ,and Almost I tried initialization of M_CAN module except the two steps for M_CAN_Tx pin and M_CAN_Rx Pin initialization. I checked the MPC5777C sample code

   

    SIU.PCR[83].R = 0x0E0C; /* MCAN0TX, push/pull, max slew rate */
    SIU.PCR[84].R = 0x0D03; /* MCAN0RX, weak pull device disabled */

pastedImage_1.png

It is clearly given for the MPC 5777C ,But for MPC 5777M

pastedImage_2.png

As per the header file <MPC5777M.h> There are MSCR_IO[512[] and MSCR_MUX[512] registers are defined. I have got

one document for MPC5777M sending CAN FD messages , where I got the following.

pastedImage_4.png

So I am confused the configure the M_CAN_Tx and Rx Pin. Can you Please help me how to configure Tx and Rx Pins ?

0 件の賞賛

1,716件の閲覧回数
yalamandadosaky
Contributor V

And there is no MSCR registers defined in header file MPC5777M.h .Only MSCR_IO and MSCR_MUX registers defined.

0 件の賞賛

1,716件の閲覧回数
martin_kovar
NXP Employee
NXP Employee

Hi,

it seems that the example you found is created in different IDE (maybe Green Hills) and it uses different header file.

So in your case you have use following construction:

SIUL2.MSCR_IO[10].R = value; /*set all required settings for MCAN1TX*/

SIUL2.MSCR_IO[11].R = value; /*set all required settings for MCAN1RX*/

SIUL.2.MSCR_MUX[246].SSS = 0x2 /*Connect MCAN1RX to PA[11]*/

I know it is little bit complicated and I hope this will help you.

If you have any other questions, please feel free to write me back.

Regards,

Martin

1,716件の閲覧回数
yalamandadosaky
Contributor V

Hi Martin Kovar@  As per the sample code you provided ,I have written the code for initializing M_CAN_1 for MPC5777M.

for sending CAN messages

void MCAN_1_Init()
{

    M_CAN_1.CCCR.B.INIT = 0x1;            // set to initialization mode
    while(M_CAN_1.CCCR.B.INIT == 0x0);    // wait till previous written value has been accepted.
    M_CAN_1.CCCR.B.CCE = 0x1;             // unlock protected registers for configuration
//    while(M_CAN_1.CCCR.B.CCE == 0x0);       // wait till previous written value has been accepted.

    M_CAN_1.CCCR.B.CMR = 0x0;             // Request CAN Mode
    M_CAN_1.CCCR.B.CME = 0x0;             // Enable CAN Mode

    M_CAN_1.TSCC.R = 0x00000000;          // Time Stamp Counter
    M_CAN_1.TOCC.R = 0x00000000;          // Time out counter

    M_CAN_1.IE.R =  0xFFFFFFFF;           // Enable all interrupts.
    M_CAN_1.ILS.R = 0xFFFFFFFF;           // Interrupt Assigns to one of the two interrupt lines.
    M_CAN_1.ILE.R = 0x00000003;           // Enable two interrupt lines.

    M_CAN_1.BTP.R = 0x00011E77;           // Set time quanta for 0.5Mbps SYNC=1, TSEG1=30+1, TSEG2=7+1, SJW=7+1

    M_CAN_1.GFC.R = 0x00111111;           // Reject Non Matching Frames
    M_CAN_1.SIDFC.R = 0x00020000;         // Configuring Two Standard ID filters and its offset address.

    M_CAN_1.TXBC.R = 0x00200300;          // Setting up 2 Tx Buffers, Transmit Buffer Offset Address
    M_CAN_1.RXF0C.R = 0x80020100;         // Setting up 5 Rx FIFO 0 with overwrite new messages when fifo full and its  offset address.
    M_CAN_1.RXF1C.R = 0x00020200;         // Setting up 5 Rx FIFO 1 with discard new messages when fifo full and its offset address
    M_CAN_1.RXESC.R = 0x00000000;         // 8 data bytes for Message FIFO 1 / 8 data bytes for Message FIFO 0
    M_CAN_1.TXESC.R = 0x00000000;         // 8 data bytes for Tx Buffer.

    M_CAN_1.CCCR.B.CCE = 0x0;             // disable CCE to prevent configuration changes
    M_CAN_1.CCCR.B.INIT = 0x0;            // Return to normal operation
    while(M_CAN_1.CCCR.B.INIT == 0x1);    // lock protected registers for configuration
    //while((M_CAN_1.CCCR.R & 0x1) == 1);
    SIUL2.MSCR_IO[10].R = 0x32000001;     // Very Strong Drive,Push-Pull output enable MCAN1TX Pin, PA[10]
    SIUL2.MSCR_IO[11].R = 0x00080002;     // Enable input buffer for MCAN1RX
    SIUL2.MSCR_MUX[246].B.SSS = 0x2;      // Connect MCAN1RX to PA[11]
}

I Flashed the same code into the board, And I tried to debug ,when it encounters the M_CAN_1.CCCR.B.CCE = 0x1;  instruction ,It is not taking.I dont why it is not taking ,Can you please help me how to resolve the issue.

0 件の賞賛

1,716件の閲覧回数
yalamandadosaky
Contributor V

The debug value is showing '0' only for the register M_CAN_1.CCCR.B.CCE = 0x1;

0 件の賞賛

1,716件の閲覧回数
yalamandadosaky
Contributor V

I thought it is not all going to initialize the CAN module ?

0 件の賞賛

1,716件の閲覧回数
yalamandadosaky
Contributor V

Hi  b55689

M_CAN_1.CCCR.B.INIT = 0x0;            // Return to normal operation
    while(M_CAN_1.CCCR.B.INIT == 0x1);

0 件の賞賛

1,714件の閲覧回数
PetrS
NXP TechSupport
NXP TechSupport

Hi,

try to move CAN TX/RX pin setting into initialization, means before clearing INIT bit at the end. Clearing this bit the module tries to synchronize to the bus, but probably cannot as pins are not set still.

BR, Petr

1,714件の閲覧回数
yalamandadosaky
Contributor V

Hi Petr Stancik, I want to the initalization for M_CAN_2 ,what are the Tx_PIN and Rx_PIN configurations ,I didn't find in the Reference Manual.

0 件の賞賛

1,714件の閲覧回数
PetrS
NXP TechSupport
NXP TechSupport

You should open an Excel sheet attached to the RM to see I/O table.

Open the RM and press CTRL+SHIFT+A, in attachment window open an Excel sheet and select IO Signal Table tab.

 

The MCAN2 TX/RX signals can be located at PA[1] and PA[2] pins so the setting could be

 

SIUL2.MSCR_IO[2].R = 0x32000001;     // Very Strong Drive,Push-Pull output enable MCAN2 TX Pin, PA[2]
SIUL2.MSCR_IO[1].B.IBE = 0x1;                  // Enable input buffer for MCAN2 RX
SIUL2.MSCR_MUX[759-512].B.SSS = 0x2;      // Connect MCAN2 RX to PA[1]

BR, Petr

1,714件の閲覧回数
yalamandadosaky
Contributor V

Hi Petr Stancik, Thank you for your reply, I Did not get any attachment with RM,So I am unable to locate it ,Currently I am using S32 IDE Power Pc V1.1 and MPC 57xx MB with MPC5777M in Ubuntu 14.04 ,

One thing I want to share with you is ,Currently I am written CAN_driver for the above hardware code as per the sample  code  provided for MPC5777C provided in the Examples provided by NXP. So I have seen the author is you only.

Currently I am working Error Handling .How we can do error handle in transmitting messages and receiving messages. I am not sure ?

0 件の賞賛

1,714件の閲覧回数
yalamandadosaky
Contributor V

Thank you, I will check it.

0 件の賞賛