infineon4engineers Facebook

infineon@google+ Google+

infineon@linkedin linkedin

infineon4engi@twitter twitter

infineon@youtube youtube

+ Reply to Thread
Results 1 to 7 of 7

Thread: trying to transmit via can

  1. #1
    Torsten Robitzki
    Guest

    trying to transmit via can

    Hello,
    currently I have a problem with transmitting via can. Maybe some kind sole could spend some minutes and have a look at this small snipped:

    Code:
            void init()
            {
                CAN_message_4.can_mo_ptr = CAN_MO4;
                CAN_message_4.can_priority = XMC_CAN_ARBITRATION_MODE_IDE_DIR_BASED_PRIO_2;
                CAN_message_4.can_identifier = 0xff;
                CAN_message_4.can_id_mask= 0xff;
                CAN_message_4.can_id_mode = XMC_CAN_FRAME_TYPE_STANDARD_11BITS;
                CAN_message_4.can_ide_mask = 1;
                CAN_message_4.can_data_length = 8;
                CAN_message_4.can_data[ 0 ] = 0x12345556;
                CAN_message_4.can_data[ 1 ] = 0x12345556;
                CAN_message_4.can_mo_type = XMC_CAN_MO_TYPE_TRANSMSGOBJ;
    
                /* Configure CAN Module */
                XMC_CAN_Init( CAN, can_frequency );
    
                /* Configure Pinnin */
                XMC_GPIO_SetMode( P1_5, XMC_GPIO_MODE_OUTPUT_PUSH_PULL_ALT1 );
                XMC_CAN_NODE_SetReceiveInput( can_node, XMC_CAN_NODE_RECEIVE_INPUT_RXDCB );
    
                /* Configure CAN Node baudrate */
                XMC_CAN_NODE_NominalBitTimeConfigure( can_node, &baud );
    
                /* NODE 1 initialization */
                XMC_CAN_NODE_ResetInitBit( can_node );
    
                /* Message 4 Configuration */
                XMC_CAN_MO_Config( &CAN_message_4, can_node_nr, 4 );
    
                /* Allocate MO in Node List */
                XMC_CAN_AllocateMOtoNodeList( CAN, can_node_nr, 4 );
    
                /*Enable nvic node*/
                NVIC_EnableIRQ(CAN0_7_IRQn);
            }
    
            void test_send()
            {
              /*Send data in CAN_message_4*/
              XMC_CAN_MO_Transmit( &CAN_message_4 );
            }
    I call the function init() once and the function test_send() periodically. XMC_CAN_MO_Transmit() returns XMC_CAN_STATUS_SUCCESS. can_node is equal to CAN_NODE1 and can_node_nr equal to 1. The code is running on a xmc4200 hexagon board. Looking at the transmission pin 1.5, I'm measuring a constant hight (~3.3V). What am I'm missing here? I'm unsure about the parameter to the XMC_CAN_MO_Config() function.

    Kind regards,
    Torsten

  2. #2
    Travis will become famous soon enough
    Join Date
    Feb 2013
    Location
    Singapore
    Posts
    749
    Points
    4580
    Hi Torsten,

    Please hang on.. I will try to get you an example.

    Best regards
    Travis

  3. #3
    Torsten Robitzki
    Guest
    Hi Travis,
    that would be wonderful. Thank you very much.

    kind regards,
    Torsten

  4. #4
    Blackom is on a distinguished road
    Join Date
    Aug 2014
    Posts
    9
    Points
    62.5
    Hi Torsten,

    I think, you must change your initial code. Firstly, You must add MO to Node and next reset init bit.
    Code:
                /* Allocate MO in Node List */
                XMC_CAN_AllocateMOtoNodeList( CAN, can_node_nr, 4 );
    
                /* NODE 1 initialization */
                XMC_CAN_NODE_ResetInitBit( can_node );
    
                /* Message 4 Configuration */
                XMC_CAN_MO_Config( &CAN_message_4, can_node_nr, 4 );
    Best regards
    Blackom

  5. #5
    Travis will become famous soon enough
    Join Date
    Feb 2013
    Location
    Singapore
    Posts
    749
    Points
    4580
    This is the CAN example using the DAVE4 LLD using loop back method.
    ?????

  6. #6
    Torsten Robitzki
    Guest
    Hallo Blackom, Hallo Travis,
    thank you very much for your input. I've incorporated your input. I've changed the init code now to reset the Init bit as one of the last actions (like in the Dave example). In addition, I use the XMC_GPIO_Init() for Pin configuration (as in the Dave example).

    In addition, I've enable frame counting to see if the hardware believes that it can transmit messages and only the pin setting is wrong.

    Unfortunately there is still no output on the can bus. If I use a debugger to inspect the frame counter, I don't see the counter increasing:
    Code:
    (gdb) p/x *can_node
    $2 = {NCR = 0x1, NSR = 0x25, NIPR = 0x0, NPCR = 0x1, NBTR = 0x1801, NECNT = 0x600000, NFCR = 0x400000}
    I see one big difference between my setting and the Dave setting. I've set the can_frequency to 12E6 while in the Dave example it's 12E7. If I use 12E7, an assert in XMC_CAN_Init() fires, because the condition can_frequency < peripheral_frequency is not satisfied. My peripheral_frequency is 8E7. Could this be a problem?

    Next on my list is, to check every register of the CAN_GLOBAL, the CAN_NODE and the Message Object. Any tipps, on what to inspect in addition?

    Here is my current init function
    Code:
            void init()
            {
                CAN_message_4.can_mo_ptr = CAN_MO4;
                CAN_message_4.can_priority = XMC_CAN_ARBITRATION_MODE_IDE_DIR_BASED_PRIO_2;
                CAN_message_4.can_identifier = 0xff;
                CAN_message_4.can_id_mask= 0xff;
                CAN_message_4.can_id_mode = XMC_CAN_FRAME_TYPE_STANDARD_11BITS;
                CAN_message_4.can_ide_mask = 1;
                CAN_message_4.can_data_length = 8;
                CAN_message_4.can_data[ 0 ] = 0x12345556;
                CAN_message_4.can_data[ 1 ] = 0x12345556;
                CAN_message_4.can_mo_type = XMC_CAN_MO_TYPE_TRANSMSGOBJ;
    
                /* Configure CAN Module */
                XMC_CAN_Init( CAN, can_frequency );
    
                /* Configure CAN Node baudrate */
                /* A valid CAN bit timing must be written to the CAN Node Bit Timing Register NBTR before
                   resetting the INIT bit in the Node Control Register, i.e. before enabling the operation of the CAN node. */
                /* this function calls XMC_CAN_NODE_EnableConfigurationChange/XMC_CAN_NODE_DisableConfigurationChange on its own */
                XMC_CAN_NODE_NominalBitTimeConfigure( can_node, &baud );
    
                XMC_CAN_NODE_EnableConfigurationChange( can_node );
                XMC_CAN_NODE_SetInitBit( can_node );
    
                /* Configure Input Pin */
                static const XMC_GPIO_CONFIG receive_pin_config = {
                    XMC_GPIO_MODE_INPUT_TRISTATE,
                    // a valid output level have to be set, even for input pins; otherwise XMC_GPIO_Init() will assert.
                    XMC_GPIO_OUTPUT_LEVEL_LOW };
                XMC_GPIO_Init( P1_4, &receive_pin_config );
                XMC_CAN_NODE_SetReceiveInput( can_node, XMC_CAN_NODE_RECEIVE_INPUT_RXDCB );
    
                XMC_CAN_NODE_EnableEvent( can_node, XMC_CAN_NODE_EVENT_CFCIE );
    
                /* Allocate MO in Node List */
                XMC_CAN_AllocateMOtoNodeList( CAN, can_node_nr, 4 );
    
                /* Message 4 Configuration */
                XMC_CAN_MO_Config( &CAN_message_4, can_node_nr, 4 );
    
                XMC_CAN_NODE_DisableConfigurationChange( can_node );
    
                /* NODE initialization */
                XMC_CAN_NODE_ResetInitBit( can_node );
    
                /* Configure Output Pin */
                static const XMC_GPIO_CONFIG_t transmit_pin_config = {
                    XMC_GPIO_MODE_OUTPUT_PUSH_PULL_ALT1,
                    XMC_GPIO_OUTPUT_LEVEL_HIGH,
                    XMC_GPIO_OUTPUT_STRENGTH_STRONG_SHARP_EDGE
                };
                XMC_GPIO_Init( P1_5, &transmit_pin_config );
    
                /*Enable nvic node*/
                NVIC_EnableIRQ(CAN0_7_IRQn);
            }

  7. #7
    Torsten Robitzki
    Guest
    I got it! Fantastic!!! Juhu :-) I got the receive Pin configuration wrong. I thought pin 1.4 was input B, as it was the 2 input in the table 22-12. But there is an addition table 15-14 that states, that P1.4 is CAN.CAN1_RXDC1D. So it's D, not B. Thank you all very much for your help.

+ Reply to Thread

Tags for this Thread

Disclaimer

All content and materials on this site are provided “as is“. Infineon makes no warranties or representations with regard to this content and these materials of any kind, whether express or implied, including without limitation, warranties or representations of merchantability, fitness for a particular purpose, title and non-infringement of any third party intellectual property right. No license, whether express or implied, is granted by Infineon. Use of the information on this site may require a license from a third party, or a license from Infineon.


Infineon accepts no liability for the content and materials on this site being accurate, complete or up- to-date or for the contents of external links. Infineon distances itself expressly from the contents of the linked pages, over the structure of which Infineon has no control.


Content on this site may contain or be subject to specific guidelines or limitations on use. All postings and use of the content on this site are subject to the Usage Terms of the site; third parties using this content agree to abide by any limitations or guidelines and to comply with the Usage Terms of this site. Infineon reserves the right to make corrections, deletions, modifications, enhancements, improvements and other changes to the content and materials, its products, programs and services at any time or to move or discontinue any content, products, programs, or services without notice.