Author Topic: CAN Interfaces on K24  (Read 66 times)

Offline AlexS

  • Newbie
  • *
  • Posts: 37
    • View Profile
CAN Interfaces on K24
« on: November 23, 2021, 11:16:01 AM »
Hi,

Switching MCUs because of the shortage and replaced the MK26FN2M0VLQ18 with the MK24FN1M0VDC12. Our product needs to use the CAN interface on the MCU, but the kinetis.h conditional compile defaults to 0 CAN interfaces for the K24. I'll hack the solution for the time being, but just wanted to make sure I'm not missing anything.

Code: [Select]
#elif defined KINETIS_K24
    #define NUMBER_OF_CAN_INTERFACES 0

Thanks!


Offline mark

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3162
    • View Profile
    • uTasker
Re: CAN Interfaces on K24
« Reply #1 on: November 23, 2021, 02:33:15 PM »
Hi Alex

The K24 with 256k Flash has no FlexCAN but the one that you use (with 1MBytes Flash) does.
Note the condition:

..(defined KINETIS_K24 && (SIZE_OF_FLASH == (1024 * 1024))).. which enables one FlexCAN interface.


// CAN configuration
//
#if defined KINETIS_KV50
    #define NUMBER_OF_CAN_INTERFACES 3
#elif defined KINETIS_KS
    #if defined KINETIS_K22
        #define NUMBER_OF_CAN_INTERFACES 2
    #else
        #define NUMBER_OF_CAN_INTERFACES 1
    #endif
#elif defined KINETIS_K64 || defined KINETIS_KW36 || (defined KINETIS_K24 && (SIZE_OF_FLASH == (1024 * 1024))) || defined KINETIS_KE06 || defined KINETIS_KEA64 || defined KINETIS_KEA128
    #define NUMBER_OF_CAN_INTERFACES 1
    #if defined KINETIS_KE06 || defined KINETIS_KEA64 || defined KINETIS_KEA128
        #define MSCAN_CAN_INTERFACE                                      // MSCAN rather than FlexCAN
    #endif
#elif (KINETIS_MAX_SPEED == 72000000) && (defined KINETIS_K20 || defined KINETIS_K30)
    #define NUMBER_OF_CAN_INTERFACES 1
#elif (KINETIS_MAX_SPEED == 120000000) && defined KINETIS_K22
    #define NUMBER_OF_CAN_INTERFACES 1
#elif defined KINETIS_K24
    #define NUMBER_OF_CAN_INTERFACES 0
#elif (KINETIS_MAX_SPEED >= 100000000) && (defined KINETIS_K10 || defined KINETIS_K20 || defined KINETIS_K26 || defined KINETIS_K30 || defined KINETIS_K40 || defined KINETIS_K60 || defined KINETIS_K65 || defined KINETIS_K66 || defined KINETIS_K70 || (defined KINETIS_KE14 && defined KINETIS_K_FPU) || defined KINETIS_KE16 || defined KINETIS_KE18)
    #define NUMBER_OF_CAN_INTERFACES 2
#else
    #define NUMBER_OF_CAN_INTERFACES 0
#endif



In fact the
#elif defined KINETIS_K24
    #define NUMBER_OF_CAN_INTERFACES 0

is probably redundant as the default is 0 FlexCANs anyway.

Therefore make sure that you have SIZE_OF_FLASH set appropriately.

Regards

Mark

Offline AlexS

  • Newbie
  • *
  • Posts: 37
    • View Profile
Re: CAN Interfaces on K24
« Reply #2 on: November 29, 2021, 10:23:07 AM »
That was indeed the problem, found it when the app first started and noticed that my stack was being placed near the start of my DATA section. Thank you!