infineon4engineers Facebook

infineon@google+ Google+

infineon@linkedin linkedin

infineon4engi@twitter twitter

infineon@youtube youtube

+ Reply to Thread
Results 1 to 6 of 6

Thread: XMC1400 E_EEPROM(dave ce) merge with blinkyMCAN Problems

  1. #1
    Beginner Beginner xtream123 is on a distinguished road
    Join Date
    Sep 2018
    Posts
    7
    Points
    95

    XMC1400 E_EEPROM(dave ce) merge with blinkyMCAN Problems

    Hi to all,
    I have compiled(DAVE 4.3.2) and tested the E_EEPROM sample code(from xmc lib) and blinkyMCAN(from https://www.infineonforums.com/archi...p/t-4234.html?) sample code separately and it is working fine.
    I encounter the problem when I am integrating both of the codes(see error below):


    'XMC_SCU_IRQCTRL_7_CAN0_SR3' undeclared (first use in this function) main.c /TempDisplay_with_EEPROM_mcanTry line 313 C/C++ Problem

    make: *** [main.o] Error 1 TempDisplay_with_EEPROM_mcanTry C/C++ Problem

    recipe for target 'main.o' failed subdir.mk /TempDisplay_with_EEPROM_mcanTry/Debug line 18 C/C++ Problem

    unknown field 'clock_sync' specified in initializer main.c /TempDisplay_with_EEPROM_mcanTry line 254 C/C++ Problem

    unknown field 'enable_automatic_dco1_calibration' specified in initializer main.c /TempDisplay_with_EEPROM_mcanTry line 254 C/C++ Problem

    The merge code with my application code is shown below:


    #include <DAVE.h>
    #include "xmc_common.h"
    #include "xmc1_flash.h"

    /************************************************** ************************************************** *****************
    * HEADER FILES
    ************************************************** ************************************************** ****************/
    #include "xmc_gpio.h"
    #include "xmc_uart.h"
    #include <stdio.h>
    #include <xmc_vadc.h>

    #include "xmc_can.h"


    /************************************************** ************************************************** *****************
    * MACROS
    ************************************************** ************************************************** *****************/
    #define TICKS_PER_SECOND 1000
    #define TICKS_WAIT 500
    #define DIS_TICKS 1000

    //Input
    #define IN1 P4_0
    #define IN2 P4_1
    #define IN3 P4_2
    #define IN4 P4_3


    //Output
    #define USERlED2 P1_7
    #define USERlED1 P1_8


    //CAN
    #define CAN1_TXD P4_9 //ALT9
    #define CAN1_RXD P4_8

    #define LED P4_0
    #define LED_TX P4_1 //CAN TX indication
    #define LED_RX P4_3 //CAN_RX indication
    XMC_GPIO_CONFIG_t led_config;
    XMC_GPIO_CONFIG_t led_TX_config;
    XMC_GPIO_CONFIG_t led_RX_config;

    const unsigned char HIGH = 255;
    const unsigned char LOW = 0;
    /************************************************** ************************************************** *****************
    * GLOBAL VARIABLES
    ************************************************** ************************************************** *****************/
    const uint8_t message[] = "Hello world!!";
    float degree;

    //adc var
    float tmax = 100;
    float tmin = 0;
    float imin = 0.004;
    float imax = 0.020;
    float currentReading = 0.017;
    float val;
    char buf[100];
    int adc;
    float vadc;

    //input button
    char upFlag = 0;
    char downFlag = 0;
    char setFlag = 0;
    char buttonFlag = 0;
    char set_status = 0;

    //temp variables
    float setValue = 25;
    char blink = 0;
    float rawSamples = 0;
    char numOfSamples = 0;
    float tempAverage = 0;
    int setTimeOut = 0;

    //c variables
    unsigned char controlEnable = 0;

    //declaration
    void test_b3(float _tempVal);

    //CAN
    /*CAN Bit time*/
    XMC_CAN_NODE_NOMINAL_BIT_TIME_CONFIG_t baud = { .can_frequency = 11000000,
    .baudrate = 500000, .sample_point = 6000, .sjw = 3, };

    /*CAN message= CAN_MO4 */
    XMC_CAN_MO_t MCAN_message1 = { .can_mo_ptr = CAN_MO4, .can_priority =
    XMC_CAN_ARBITRATION_MODE_IDE_DIR_BASED_PRIO_2, .can_identifier = 0x3ff,
    .can_id_mask = 0x7ff, .can_id_mode = XMC_CAN_FRAME_TYPE_STANDARD_11BITS,
    .can_ide_mask = 1, .can_data_length = 8, .can_data = { 0x12345555,
    0x12345556 }, .can_mo_type = XMC_CAN_MO_TYPE_TRANSMSGOBJ };

    /*CAN message= CAN_MO2 */
    XMC_CAN_MO_t MCAN_message2 = { .can_mo_ptr = CAN_MO2, .can_priority =
    XMC_CAN_ARBITRATION_MODE_IDE_DIR_BASED_PRIO_2, .can_identifier = 0x2ff,
    .can_id_mask = 0x2ff, .can_id_mode = XMC_CAN_FRAME_TYPE_STANDARD_11BITS,
    .can_ide_mask = 1, .can_data_length = 8, .can_mo_type =
    XMC_CAN_MO_TYPE_RECMSGOBJ };

    /************************************************** ************************************************** *****************
    * SER_DATA STRUCTURES
    ************************************************** ************************************************** *****************/
    /* UART configuration */
    XMC_UART_CH_CONFIG_t uart_config = { .baudrate = 19200, .data_bits = 8U,
    .frame_length = 8U, .stop_bits = 1U, .parity_mode =
    XMC_USIC_CH_PARITY_MODE_NONE };

    /* UART Tx and Rx Pins */
    XMC_GPIO_CONFIG_t rx_pin_config = { .mode = XMC_GPIO_MODE_INPUT_PULL_UP, };

    XMC_GPIO_CONFIG_t tx_pin_config = { .mode = XMC_GPIO_MODE_OUTPUT_PUSH_PULL_ALT7 // Tx output in ALT7
    };

    /* GPIO LED pin configuration */
    XMC_GPIO_CONFIG_t led_pin_config = { .mode = XMC_GPIO_MODE_OUTPUT_PUSH_PULL,
    .output_level = 1U };

    /************************************************** ************************************************** *****************
    * SER_DATA STRUCTURES
    ************************************************** ************************************************** *****************/
    /* GPIO LED pin configuration */
    XMC_GPIO_CONFIG_t LED_pin_config_output = { .mode =
    XMC_GPIO_MODE_OUTPUT_PUSH_PULL,
    //.output_level = 1U
    .output_level = XMC_GPIO_OUTPUT_LEVEL_LOW };

    XMC_GPIO_CONFIG_t LED_pin_config_input =
    { .mode = XMC_GPIO_MODE_INPUT_TRISTATE };

    /************************************************** ************************************************** *****************
    * VADC CONFIG
    ************************************************** ************************************************** *****************/

    /* VADC Global resources data configuration. Divider factor for the analog
    * internal clock is set => fADCI = 120 MHz / (DIVA+1) */
    const XMC_VADC_GLOBAL_CONFIG_t g_global_handle = { .clock_config = {
    .analog_clock_divider = 3, }, };

    /* VADC group data configuration. No configuration needed, standard values
    * are used. */
    const XMC_VADC_GROUP_CONFIG_t g_group_handle = { };

    /* Data configuration for background source. */
    const XMC_VADC_BACKGROUND_CONFIG_t g_bgn_handle = { };

    /* Channel data configuration. Channel does NOT use alias feature and uses
    * desired result register. */
    const XMC_VADC_CHANNEL_CONFIG_t g_g1_ch7_handle = { .alias_channel =
    XMC_VADC_CHANNEL_ALIAS_DISABLED, .result_reg_number = 7, };

    ///
    XMC_VADC_RESULT_SIZE_t result = 0;

    /************************************************** ************************************************** *****************
    * LOCAL ROUTINES
    ************************************************** ************************************************** *****************/
    void SysTick_Handler(void) {
    uint32_t index;
    static uint32_t ticks = 0;
    static uint32_t disTicks = 0;

    ticks++;
    disTicks++;

    if (ticks == TICKS_WAIT) {
    XMC_CAN_MO_Transmit(&MCAN_message1);

    //get ADC reading
    result = XMC_VADC_GROUP_GetResult(VADC_G1, 7);
    //convert to temp
    adc = result;
    vadc = ((adc * 5.0) / 4095);
    currentReading = vadc / 248;
    val = (tmax - tmin) / (imax - imin);
    val = val * (currentReading - imin) + tmin;



    rawSamples += val;
    numOfSamples++;

    if (numOfSamples >= 10) { //get average
    val = rawSamples / 10;
    numOfSamples = 0;
    rawSamples = 0;
    tempAverage = val;

    }

    //===========DISPLAY conditions=============//
    if (set_status == 0) { //normal display
    test_b3(tempAverage);
    } else { //dont update the display when set button is pressed
    setTimeOut++;
    if (setTimeOut > 40) {//no button press or action go back to normal display
    //reset set flags
    setTimeOut = 0;
    set_status = 0;
    setFlag = 0;
    println("Set timeout! Last action not saved");
    }
    }

    if (blink == 1) {
    blink = 0;
    } else {
    blink = 1;
    }

    if (controlEnable == 1) {

    }

    ticks = 0; //clear ticks
    }
    }

    XMC_SCU_CLOCK_CONFIG_t clock_config = { .dclk_src = XMC_SCU_CLOCK_DCLKSRC_DCO1,
    .oschp_mode = XMC_SCU_CLOCK_OSCHP_MODE_OSC,
    .enable_automatic_dco1_calibration = true, .clock_sync =
    XMC_SCU_CLOCK_SYNC_CLKSRC_OSCHP, //XMC_SCU_CLOCK_SYNC_CLK_OSCLP,
    .pclk_src = XMC_SCU_CLOCK_PCLKSRC_DOUBLE_MCLK, .fdiv = 0, //Fractional divider
    .idiv = 1 //MCLK = 48MHz
    };

    uint32_t mode = 0;

  2. #2
    Beginner Beginner xtream123 is on a distinguished road
    Join Date
    Sep 2018
    Posts
    7
    Points
    95
    //Continued here

    /************************************************** ************************************************** *****************
    * INITIALIZATION & FUNCTION IMPLEMENTATION
    ************************************************** ************************************************** *****************/
    int main(void) {
    //CAN
    /*Led on Board Initialization*/
    XMC_SCU_CLOCK_Init(&clock_config);
    led_config.mode = XMC_GPIO_MODE_OUTPUT_PUSH_PULL;
    XMC_GPIO_Init(LED, &led_config);

    /* System timer configuration */
    SysTick_Config(SystemCoreClock / TICKS_PER_SECOND);
    NVIC_SetPriority(SysTick_IRQn, 0);

    XMC_GPIO_CONFIG_t CAN1_TXD_config;
    XMC_GPIO_CONFIG_t CAN1_RXD_config;
    CAN1_TXD_config.mode = XMC_GPIO_MODE_OUTPUT_PUSH_PULL_ALT9;
    CAN1_RXD_config.mode = XMC_GPIO_MODE_INPUT_TRISTATE;
    XMC_GPIO_Init(CAN1_TXD, &CAN1_TXD_config);
    XMC_GPIO_Init(CAN1_RXD, &CAN1_RXD_config);

    /*Configure CAN Module*/
    XMC_CAN_Init(CAN, XMC_CAN_CANCLKSRC_MCLK, 11000000);

    XMC_CAN_NODE_EnableConfigurationChange(CAN_NODE1);
    XMC_CAN_NODE_SetReceiveInput(CAN_NODE1, XMC_CAN_NODE_RECEIVE_INPUT_RXDCC);
    XMC_CAN_NODE_DisableConfigurationChange(CAN_NODE1) ;

    /*NODE 1 initialization*/
    XMC_CAN_NODE_EnableConfigurationChange(CAN_NODE1);
    XMC_CAN_NODE_NominalBitTimeConfigure(CAN_NODE1, &baud);
    XMC_CAN_NODE_DisableConfigurationChange(CAN_NODE1) ;

    led_TX_config.mode = XMC_GPIO_MODE_OUTPUT_PUSH_PULL;
    led_TX_config.output_level = XMC_GPIO_OUTPUT_LEVEL_HIGH;
    XMC_GPIO_Init(LED_TX, &led_TX_config);
    led_RX_config.mode = XMC_GPIO_MODE_OUTPUT_PUSH_PULL;
    led_RX_config.output_level = XMC_GPIO_OUTPUT_LEVEL_HIGH;
    XMC_GPIO_Init(LED_RX, &led_RX_config);

    /*Message 4 Configuration - Transmit*/
    XMC_CAN_MO_Config(&MCAN_message1);

    /* Message 2 Configuration - Receive */
    XMC_CAN_MO_Config(&MCAN_message2);

    /* Enable receive event */
    XMC_CAN_MO_EnableEvent(&MCAN_message2, XMC_CAN_MO_EVENT_RECEIVE);
    // XMC_CAN_NODE_EnableEvent(CAN_NODE1, XMC_CAN_NODE_EVENT_TX_INT);

    /* Set receive interrupt Service request number*/
    XMC_SCU_SetInterruptControl(7, XMC_SCU_IRQCTRL_7_CAN0_SR3);
    XMC_CAN_MO_SetEventNodePointer(&MCAN_message2,
    XMC_CAN_MO_POINTER_EVENT_RECEIVE, 3);
    NVIC_SetPriority(IRQ7_IRQn, 1);
    NVIC_EnableIRQ(IRQ7_IRQn);

    /* Allocate MO in Node List*/
    XMC_CAN_AllocateMOtoNodeList(CAN, 1, 4);
    XMC_CAN_AllocateMOtoNodeList(CAN, 1, 2);
    XMC_CAN_NODE_ResetInitBit(CAN_NODE1);

    //UART

    /* Configure UART channel */
    XMC_UART_CH_Init(XMC_UART0_CH1, &uart_config);
    /* Configure input multiplexor */
    XMC_UART_CH_SetInputSource(XMC_UART0_CH1, XMC_UART_CH_INPUT_RXD, 0);
    /* Start UART channel */
    XMC_UART_CH_Start(XMC_UART0_CH1);

    /* Initialize GPIO */
    XMC_GPIO_Init(P1_3, &rx_pin_config);
    XMC_GPIO_Init(P1_2, &tx_pin_config);

    //Input

    //Output

    /* Setup system timer to send a message via UART periodically */
    SysTick_Config(SystemCoreClock / TICKS_PER_SECOND);
    /* ****************************** VADC ****************************** */
    /* Provide clock to VADC and initialize the VADC global registers. */
    XMC_VADC_GLOBAL_Init(VADC, &g_global_handle);

    /* Initialize the conversion kernel. */
    XMC_VADC_GROUP_Init(VADC_G1, &g_group_handle);

    /* Set VADC group to normal operation mode (VADC kernel). */
    XMC_VADC_GROUP_SetPowerMode(VADC_G1, XMC_VADC_GROUP_POWERMODE_NORMAL);

    /* Calibrate the VADC. Make sure you do this after all used VADC groups
    * are set to normal operation mode. */
    XMC_VADC_GLOBAL_StartupCalibration(VADC);

    /* Initialize the background source hardware. The gating mode is set to
    * ignore to pass external triggers unconditionally.*/
    XMC_VADC_GLOBAL_BackgroundInit(VADC, &g_bgn_handle);

    /* Initialize the channel unit. */
    XMC_VADC_GROUP_ChannelInit(VADC_G1, 7, &g_g1_ch7_handle);

    /* Add a channel to the background source. */
    XMC_VADC_GLOBAL_BackgroundAddChannelToSequence(VAD C, 1, 7);

    /* Enables autoscan feature for continuous conversion. */
    XMC_VADC_GLOBAL_BackgroundEnableContinuousMode(VAD C);

    /* Generate conversion request (load event). */
    XMC_VADC_GLOBAL_BackgroundTriggerConversion(VADC);

    ///EEEEEEPROM
    DAVE_STATUS_t status;
    E_EEPROM_XMC1_OPERATION_STATUS_t oper_status;

    uint8_t Index;
    uint8_t ReadBuffer1[12];
    uint8_t ReadBuffer2[32];
    uint8_t ReadBuffer3[100];
    uint8_t data_buffer[100];

    // Fill the buffer with incremental data from 0 to 100
    for (Index = 0; Index < 100; Index++) {
    data_buffer[Index] = Index;
    }

    char tempBuff[12] = { 0xDE, 0xAD, 0xBE, 0xAF, 0xDE, 0xAD, 0xBE, 0xAF, 0xDE,
    0xAD, 0xBE, 0xAF };

    //Clear the Read buffer before accepting the read request
    for (Index = 0; Index < 12; Index++) {
    ReadBuffer1[Index] = 0;
    }

    //Clear the Read buffer before accepting the read request
    for (Index = 0; Index < 32; Index++) {
    ReadBuffer2[Index] = 0;
    }

    //Clear the Read buffer before accepting the read request
    for (Index = 0; Index < 100; Index++) {
    ReadBuffer3[Index] = 0;
    }


    // XMC_FLASH_ErasePages( (uint32_t*)E_EEPROM_XMC1_FLASH_BANK0_BASE,16);

    status = DAVE_Init(); //Initialization of DAVE APPs

    oper_status = E_EEPROM_XMC1_OPERATION_STATUS_SUCCESS;
    // Read the latest copies of the written blocks from the active bank
    //if (oper_status == E_EEPROM_XMC1_OPERATION_STATUS_SUCCESS) {
    if (status == DAVE_STATUS_SUCCESS) {
    oper_status = E_EEPROM_XMC1_Read(temp_data, 0U, ReadBuffer1, 12U);
    for (char x = 0; x < 12; x++) {
    XMC_UART_CH_Transmit(XMC_UART0_CH1, ReadBuffer1[x]);
    }
    XMC_UART_CH_Transmit(XMC_UART0_CH1, '\r');
    XMC_UART_CH_Transmit(XMC_UART0_CH1, '\n');
    }

    setValue = (float) ReadBuffer1[0];

    prepareDisplay();
    outputDisplay();

    test_b3(setValue);

    controlEnable = 0;
    if (oper_status == E_EEPROM_XMC1_OPERATION_STATUS_SUCCESS) {
    controlEnable = 1;
    } else {
    controlEnable = 0;
    }
    //controlEnable

    float prevSetValue;

    while (1) { /* Infinite loop *///application code



    } //while(1)
    }

    /*This function is the Interrupt Event Handler for the CAN Node*/
    void IRQ7_Handler(void) {
    /* Toggle LED Pin 4.3 to indicate that the requested message is received*/
    XMC_CAN_MO_Receive(&MCAN_message2);
    XMC_GPIO_ToggleOutput(LED_RX);
    NVIC_ClearPendingIRQ(IRQ7_IRQn);
    }


    void prepareDisplay() { //GPIO codes..

    }

    void outputDisplay() { //GPIO codes..

    }

    void test_b3(float _tempVal) { //for driving the seven segment

    }

    void println(const unsigned char *p) {//display in UART

    }

    void print(const unsigned char *p) {//display in UART
    }



    //////////////////END////////////////////////



    I hope you can help me with my problem or you can redirect me to a post with same issue. Thank you

  3. #3
    Beginner Beginner xtream123 is on a distinguished road
    Join Date
    Sep 2018
    Posts
    7
    Points
    95
    Any suggestions from Infineon.....

  4. #4

    Infineon Employee
    Infineon Employee
    jferreira will become famous soon enough
    Join Date
    Oct 2012
    Posts
    401
    Hi,

    Please ensure you are using a project for the XMC1400 device supporting CAN, XMC1403 or XMC1404.
    You can check in the project properties, Microcontroller Info the device selected.

    Regards,
    Jesus
    The views expressed here are my personal opinions, have not been reviewed or authorized by Infineon and do not necessarily represent the views of Infineon.

  5. #5
    Beginner Beginner xtream123 is on a distinguished road
    Join Date
    Sep 2018
    Posts
    7
    Points
    95
    Hi Jesus,
    Thank you for your suggestion. I have checked the project properties and it support CAN.

    Do you have a sample program for using the emulated eeprom without using the dave apps?(the error above happens if place the blinkyMcan code to the e_eeprom codes).
    Or sample program for using the flash library(to store data) for XMC1400. BTW Im using XMC1400 Bootkit.

    Thank you and I hope you can help me with this.

    Regards,
    Ilde
    Last edited by xtream123; Oct 2nd, 2018 at 12:14 AM.

  6. #6
    Beginner Beginner xyyeh is on a distinguished road
    Join Date
    Aug 2017
    Posts
    5
    Points
    140
    After instantiating the emulated eeprom app in the a CE project, you can simply copy the Dave/generated folder to the IDE project.

+ 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.