Any Appnote on CAN for FRDM-KE06Z Board?

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

Any Appnote on CAN for FRDM-KE06Z Board?

3,732件の閲覧回数
Amit_Kumar1
Senior Contributor II

Hi

I have recently bought two FRDM-KE06Z board to understand the working of CAN protocol by communicating b/w these boards. Is there any appnote available from which I can implement this and get it working? I am using Codewarrior, and will be working on CAN for the first time. I have read the CAN specifications from Bosch and Freescale. now want to implement it. If anyone can give some pointers, It will be beneficial for me. Thanks in advance.


Kind Regards

Amit

11 返答(返信)

2,291件の閲覧回数
china-imm-fae-b
NXP Employee
NXP Employee

Hi, There are mistakes of the FRDM-KE06 CAN Sample code, Because of the CAN baud rate.

I  share the code on the below website:

http://www.openfsl.com/thread-48-1-1.html

#include "stdio.h"

#define TSEG_1                                                   0x00                        /*!< 1 Tq clock cycle. */

#define TSEG_2                                                   0x01                        /*!< 2 Tq clock cycle. */

#define TSEG_3                                                   0x02                        /*!< 3 Tq clock cycle. */

#define TSEG_4                                                   0x03                        /*!< 4 Tq clock cycle. */

#define TSEG_5                                                   0x04                        /*!< 5 Tq clock cycle. */

#define TSEG_6                                                   0x05                        /*!< 6 Tq clock cycle. */

#define TSEG_7                                                   0x06                        /*!< 7 Tq clock cycle. */

#define TSEG_8                                                   0x07                        /*!< 8 Tq clock cycle. */

#define TSEG_9                                                   0x08                        /*!< 9 Tq clock cycle. */

#define TSEG_10                                                   0x09                        /*!< 10 Tq clock cycle. */

#define TSEG_11                                                   0x0a                        /*!< 11 Tq clock cycle. */

#define TSEG_12                                                   0x0b                        /*!< 12 Tq clock cycle. */

#define TSEG_13                                                   0x0c                        /*!< 13 Tq clock cycle. */

#define TSEG_14                                                   0x0d                        /*!< 14 Tq clock cycle. */

#define TSEG_15                                                   0x0e                        /*!< 15 Tq clock cycle. */

#define TSEG_16                                                   0x0f                        /*!< 16 Tq clock cycle. */

#define SJW_1TQ                        0x00                        /*!< 1 Tq clock cycle. */

#define SJW_2TQ                        0x01                        /*!< 2 Tq clock cycle. */

#define SJW_3TQ                        0x02                        /*!< 3 Tq clock cycle. */

#define SJW_4TQ                        0x03                        /*!< 4 Tq clock cycle. */

#define  BUS_CLK_HZ                20000000L

#define BAUD_RATE_CLOCK                                BUS_CLK_HZ/*!< clock source for MSCAN*/

#define Baud_RATE                                        BAUD_RATE_CLOCK/(BAUD_RATE_BRP+1)/\

                                                                        (3 + BAUD_RATE_TSEG1+BAUD_RATE_TSEG2)

#define BAUD 250

#if BAUD == 1000                //1M

        #define BAUD_RATE_SJW                     SJW_3TQ        /*!< 1 set Synchronization Jump Width. */

        #define BAUD_RATE_BRP                                1                /*!< 1 Baud Rate Prescaler */       

        #define BAUD_RATE_SAMP                                0                /*!< 0-One sample per bit, 1-three sample per bit. */       

        #define BAUD_RATE_TSEG1                                TSEG_5  /*!< Time Segment 1*/

        #define BAUD_RATE_TSEG2                                TSEG_4  /*!< Time Segment 2*/

#elif BAUD == 500                //500K

        #define BAUD_RATE_SJW                     SJW_3TQ        /*!< 1 set Synchronization Jump Width. */

        #define BAUD_RATE_BRP                                1                /*!< 1 Baud Rate Prescaler */       

        #define BAUD_RATE_SAMP                                0                /*!< 0-One sample per bit, 1-three sample per bit. */       

        #define BAUD_RATE_TSEG1                                TSEG_10  /*!< Time Segment 1*/

        #define BAUD_RATE_TSEG2                                TSEG_9  /*!< Time Segment 2*/

                                                                                       

#elif BAUD == 250                //250K

        #define BAUD_RATE_SJW                     SJW_3TQ        /*!< 1 set Synchronization Jump Width. */

        #define BAUD_RATE_BRP                                7                /*!< 1 Baud Rate Prescaler */       

        #define BAUD_RATE_SAMP                                0                /*!< 0-One sample per bit, 1-three sample per bit. */       

        #define BAUD_RATE_TSEG1                                TSEG_5  /*!< Time Segment 1*/

        #define BAUD_RATE_TSEG2                                TSEG_4  /*!< Time Segment 2*/

#endif

int main()

{                                                               

        int bd = Baud_RATE;

        printf("bd is %d\r\n",bd);                                                                       

}

2,292件の閲覧回数
ivadorazinova
NXP Employee
NXP Employee

Hi Amit Kumar,


No. We have not any AN for FRDM-KE06Z for CAN. Only for KE06 CAN Boot Loader Design,

you can see it on websites Freescale Freedom Development Platform for Ki|Freescale

I can recommend to see following AN which were created for S12. It could be similar.

Using MSCAN on the MagniV Family

http://cache.freescale.com/files/microcontrollers/doc/app_note/AN4975.pdf

Using MSCAN on the HCS12 Family

http://cache.freescale.com/files/microcontrollers/doc/app_note/AN3034.pdf

Maybe you can also find useful the threads

Where would I find a reference manual for the various methods for a CAN logical device driver in CW ...

CAN driver code example for Kinetis K60

I hope it helps,

Iva

2,292件の閲覧回数
Amit_Kumar1
Senior Contributor II

Thanks Iva for quick response.

I will go through these and will try to make it work.

Regards

Amit

0 件の賞賛
返信

2,292件の閲覧回数
thomasolenik
Contributor III

Amit,

Were you able to get CAN to work on this board? If you were successful, could you share how you did it? I am trying to use the same board in my first use of CAN.  I tried using the examples given in the KDS help files and code generated by Processor Expert, but with an oscilloscope on CANH and CANL, both pins remain at 2.1V.  Did you have to supply external power or was the USB power enough?

Thanks,

Tom

0 件の賞賛
返信

2,292件の閲覧回数
davidsherman
Senior Contributor I

I have used the CAN on the FRDM-KE06 board, and the USB power was sufficient.  I was porting CAN code from an HC08, but the only thing I found on the KE06 board was having to change the SIM_PINSEL1 register to use the right pins for freedom board.  The internal clock source could drive the CAN module for evaluation purposes, but the internal clock isn't stable enough for field applications.  I found out from Freescale it is possible to use the freedom board's 8 MHz crystal with the oscillator to provide a stable clock for the MSCAN while the core is running from the internal clock at 48MHz.  Running the core off the crystal oscillator is possible, but using an 8 or 16 MHz crystal you can only get to 40MHz.

2,292件の閲覧回数
normansiegel
NXP Employee
NXP Employee

Also, if you are looking for CAN demo software, visit the FRDM-KE06Z webpage.  On the Downloads tab you should find a link for "KEXX_DRIVERS_V1.2.1_DEVD".

In this package there are CAN demo projects for the FRDM-KE06.  You'll need to populate the 0.100"C CAN header J11 on each board, then connect them with a cable.  You could also solder wires directly if you don't have headers and a cable.

I have used the CAN_Node1WithInt_demo for one Freedom board and CAN_Node2_demo for another Freedom board.  This combination works out of the box and will send CAN data between the two Freedom boards.  The CAN message for to/from each Freedom board can be monitored through the OpenSDA comm ports and a serial port program.

This is bare metal code and doesn't use the KSDK. 

Regards,

Norm

2,292件の閲覧回数
Amit_Kumar1
Senior Contributor II

Hi Norman

The project was not opening in CW 10.6 when I tried importing the project. Can You please confirm if I imported the correct files ?

Untitled.jpg

Untitled1.jpg

I cleaned the project and then tried to build it. But it didn't work. Please correct me to make it work. Thanks in advance.

Kind Regards

Amit

0 件の賞賛
返信

2,291件の閲覧回数
normansiegel
NXP Employee
NXP Employee

Hi Amit,

I set my workspace to the location where I extracted the files to - in my case C:\atemp\kexx_drv_lib.  I then used the import wizard to select the two CAN projects (see screen captures).  For me, both projects built without errors (there were some warnings, though).

Hope this helps!

Norm

2015-03-25_16-58-18.png

2015-03-25_16-59-46.png

2015-03-25_17-05-28.png


2,292件の閲覧回数
Amit_Kumar1
Senior Contributor II

Hi Norman

I followed your way but still I am getting the same issues on both the projects.....

i.jpg

Can you attach the project you have build.

Regards

Amit

0 件の賞賛
返信

2,291件の閲覧回数
normansiegel
NXP Employee
NXP Employee

Hi Amit,

Here are the exported projects.  Hope this helps!

Norm

2,292件の閲覧回数
Amit_Kumar1
Senior Contributor II

Hi Norman

Thanks for the quick reply. I will try this way. I think the way I tried should also work, wondering what wrong did it happened. Anyways I will update you soon once that is done.

Regards

Amit

0 件の賞賛
返信