Hi
Can someone help me with the following.
I am writing a firmware for a prototype level electric two wheeler coustom VCU(S32k146) . I am using S32DS with EAR SDK 0.8.6.
Brief Architecture
/*
* Copyright (c) 2015 - 2016 , Freescale Semiconductor, Inc.
* Copyright 2016-2017 NXP
* All rights reserved.
*
* THIS SOFTWARE IS PROVIDED BY NXP "AS IS" AND ANY EXPRESSED OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL NXP OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
* THE POSSIBILITY OF SUCH DAMAGE.
*/
/* Including needed modules to compile this module/procedure */
#include "Cpu.h"
#include "clockMan1.h"
#include "pin_mux.h"
#if CPU_INIT_CONFIG
#include "Init_Config.h"
#endif
volatile int exit_code = 0;
/* User includes (#include below this line is not maintained by Processor Expert) */
#include <stdint.h>
#include <stdbool.h>
/* This example is setup to work by default with EVB. To use it with other boards
please comment the following line
*/
#define GPIO_PORTA PTA
#define GPIO_PORTB PTB
#define GPIO_PORTC PTC
#define GPIO_PORTD PTD
#define GPIO_PORTE PTE
#define Right_Indicator 1U//PTD
#define Left_Indicator 0U//PTD
#define GLYPH1 14//PTC
#define GLYPH2 15//PTC
//#define GLYPH3 16//PTC
//#define GLYPH4 17//PTC
#define Cluster_Screen_Trig 7//PTE
#define Battery_Unlock 1//PTE
#define Boot_Unlock 11//PTE
#define Discharge_Contactor 16//PTD
#define Charge_Contactor 9//PTE
#define Motor_Ignition 11//PTA
#define Motor_Park 2//PTE
#define Light_Sound_Relay 0//PTC
#define Throttle_Relay 3//PTB
#define Display_Ignition_Relay 2//PTB
#define SL_Motor_Op1 5//PTB OLD CONFIG//PTC16 // INB
#define SL_Motor_Op2 8//PTE OLD CONFIG//PTC17 // INA
//CAN Tx Frame ID and MAILBOX Setup for CAN_PAL1
#define TX1VOLTAGE_MAILBOX_1 (1UL)
#define TX1VOLTAGE_ID1 (0x100)
#define TX1SOC_MAILBOX_2 (2UL)
#define TX1SOC_ID2 (0x101)
#define TX1STATUS_MAILBOX_3 (3UL)
#define TX1STATUS_ID3 (0x102)
#define TX1TEMP1_MAILBOX_4 (4UL)
#define TX1TEMP1_ID4 (0x105)
#define TX1TEMP2_MAILBOX_5 (5UL)
#define TX1TEMP2_ID5 (0x106)
//CAN Rx Frame ID and MAILBOX Setup for CAN_PAL1
#define RX1VOLTAGE_MAILBOX_1 (6UL)
#define RX1VOLTAGE_ID1 (0x100)
#define RX1SOC_MAILBOX_2 (7UL)
#define RX1SOC_ID2 (0x101)
#define RX1STATUS_MAILBOX_3 (8UL)
#define RX1STATUS_ID3 (0x102)
#define RX1TEMP1_MAILBOX_4 (9UL)
#define RX1TEMP1_ID4 (0x105)
#define RX1TEMP2_MAILBOX_5 (10UL)
#define RX1TEMP2_ID5 (0x106)
//CAN Tx Frame ID and MAILBOX Setup for CAN_PAL2
#define TX2VOLTAGE_MAILBOX_1 (21UL)
#define TX2VOLTAGE_ID1 (0x100)
#define TX2SOC_MAILBOX_2 (22UL)
#define TX2SOC_ID2 (0x101)
#define TX2STATUS_MAILBOX_3 (23UL)
#define TX2STATUS_ID3 (0x102)
#define TX2TEMP1_MAILBOX_4 (24UL)
#define TX2TEMP1_ID4 (0x105)
#define TX2TEMP2_MAILBOX_5 (25UL)
#define TX2TEMP2_ID5 (0x106)
#define TX2stefen_SOC_MAILBOX_6 (26UL)
#define TX2stefen_SOC_ID6 (0x310)
//Vehicle CAN
#define Vehicle_STAT_MAILBOX_7 (27UL)
#define Vehicle_SUBSYS_STAT_MAILBOX_8 (28UL)
#define Vehicle_STAT_ID1 (0x201)
#define Vehicle_SUBSYS_STAT_ID2 (0x202)
//Vehicle STAT Message Struct
can_message_t Vehicle_STAT = {
.cs = 0U,
.id = 0x201,
.data = {0}, // Initialize all bytes to 0
.length = 8U
};
//Vehicle SUBSYS Message Struct
can_message_t Vehicle_SUBSYS_STAT = {
.cs = 0U,
.id = 0x202,
.data = {0}, // Initialize all bytes to 0
.length = 8U
};
// RFID command frames
uint8_t Inventory_cmd[5] = {0x03,0x2F,0x01,0x2D};
uint8_t Blankarray[11];
uint32_t Timeout = 100; /* Timeout in ms for blocking operations */
uint8_t Motor_CAN_Receive =0;
uint8_t arrayindex = 0 ;
uint8_t arrayindex1 = 0;
uint8_t arrayindex2 = 0 ;
// SYSTEM STATES and SYSTEM VARIABLES Initiations
uint8_t SYSTEM_AUTH,SYSTEM_PARK,SYSTEM_ON,SYSTEM_READY,SYSTEM_MOVING = 0;
uint16_t stefen_SOC;
uint16_t micronix_voltage,stefen_voltage;
uint8_t Kill_Switch, Push_Button, Brake, Steering_Lock_STAT, Battery_Lock, Side_Stand, Charger_Connect,Battery_Dock_STAT,CHARGING,BATTERY_LOCKED,BOOT_LOCKED;
uint8_t Battery_High_Temp, Motor_High_Temp,Battery_Malfunction,Motor_Malfunction;
//System Status
status_t can_status;
void delay(volatile int cycles)
{
/* Delay function - do nothing for a number of cycles */
while(cycles--);
}
void BoardInit(void)
{
/* Initialize and configure clocks
* - Setup system clocks, dividers
* - Configure FlexCAN clock, GPIO, LPSPI
* - see clock manager component for more details
*/
CLOCK_SYS_Init(g_clockManConfigsArr, CLOCK_MANAGER_CONFIG_CNT,
g_clockManCallbacksArr, CLOCK_MANAGER_CALLBACK_CNT);
CLOCK_SYS_UpdateConfiguration(0U, CLOCK_MANAGER_POLICY_FORCIBLE);
/* Initialize pins
* - Init FlexCAN, LPSPI and GPIO pins
* - See PinSettings component for more info
*/
PINS_DRV_Init(NUM_OF_CONFIGURED_PINS, g_pin_mux_InitConfigArr);
}
void Screen_Trigger_ON (void)
{
//Battery Pack Unlock
if((PTD -> PDIR & (1<<2)) == 0 ) //Soft switch one pressed for Battery Unlock
{
PINS_DRV_WritePin(GPIO_PORTE,Battery_Unlock,1);
delay (100000);//adjust the delay based on the actuator duty cycle
PINS_DRV_WritePin(GPIO_PORTE,Battery_Unlock,0);
}
//Boot Unlock Operation
if((PTD -> PDIR & (1<<3)) == 0 ) //Soft switch two pressed for Boot Unlock
{
PINS_DRV_WritePin(GPIO_PORTE,Boot_Unlock,1);
delay (12500000);//adjust the delay based on the actuator duty cycle
PINS_DRV_WritePin(GPIO_PORTE,Boot_Unlock,0);
}
// //Charging_Contactor Operation
// if((PTD -> PDIR & (1<<4)) == 0 ) //Soft switch two state
// {
// PINS_DRV_WritePin(GPIO_PORTE,Charge_Contactor,1);//Charging Contactor Turned ON
// CHARGING = 1;//Flag raised for Charging
// }
// else if ((PTD -> PDIR & (1<<4)) != 0 )
// {
// PINS_DRV_WritePin(GPIO_PORTE,Charge_Contactor,0);//Charging Contactor Turned OFF
// CHARGING = 0;//Flag raised for Charging Disconnect
// }
}
void CHARGING_OPERATION (void)
{
if (SYSTEM_AUTH == 1 && (PTA->PDIR & (1<<6)) == 0) //PB2 High Detected - Charger Connector Plugged In
{
CHARGING =1;
PINS_DRV_WritePin(GPIO_PORTB,Throttle_Relay,0); //Throttle Disable
PINS_DRV_WritePin(GPIO_PORTE,Motor_Park,0); //SONACOM M.CON START SEQ
PINS_DRV_WritePin(GPIO_PORTC,Light_Sound_Relay,0); // Lighting OFF
PINS_DRV_WritePin(GPIO_PORTD,Discharge_Contactor,0); //Discharge Contactor Turned OFF
delay(10000000);
PINS_DRV_WritePin(GPIO_PORTE,Charge_Contactor,1);//Charging Contactor Turned ON
}
else
{
PINS_DRV_WritePin(GPIO_PORTE,Charge_Contactor,0);//Charging Contactor Turned ON
CHARGING = 0;
}
}
// If the battery is swappable this applies.
//void Discharge_CONTACTOR_ON (void)
//{
// if ((PTE -> PDIR & (1<<0)) == 0)//Battery Position Switch
// {
// PINS_DRV_WritePin(GPIO_PORTD,Discharge_Contactor,1); //Discharge Contactor ON
// BATTERY_LOCKED = 1;
// }
// else
// {
// BATTERY_LOCKED = 0;
// }
//}
void Steering_Unlock(void)
{
//if((PTE->PDIR & (1<<4)) == 0 && (PTE->PDIR & (1<<3)) != 1 ) // this condition checks the LOCK state piston position (it should satisify the lock state piston position)
//{
PINS_DRV_WritePin(GPIO_PORTB, SL_Motor_Op1,0);
PINS_DRV_WritePin(GPIO_PORTE, SL_Motor_Op2,1);
delay (750000); //map this delay to around the same time till it unlock
PINS_DRV_WritePin(GPIO_PORTB, SL_Motor_Op1,0);
PINS_DRV_WritePin(GPIO_PORTE, SL_Motor_Op2,0);
//}
}
void Steering_lock(void)
{
//if((PTE->PDIR & (1<<4)) == 0 && (PTE->PDIR & (1<<3)) != 1 ) // this condition checks the LOCK state piston position (it should satisify the lock state piston position)
//{
PINS_DRV_WritePin(GPIO_PORTB, SL_Motor_Op1,1);
PINS_DRV_WritePin(GPIO_PORTE, SL_Motor_Op2,0);
delay (750000); //map this delay to around the same time till it locks
PINS_DRV_WritePin(GPIO_PORTB, SL_Motor_Op1,0);
PINS_DRV_WritePin(GPIO_PORTE, SL_Motor_Op2,0);
//}
}
void Indicator_Light_Start_Stop (void)
{
// flag required to run this function once when called upon
// static bool functionExecuted = false;
// if(!functionExecuted)
//
PINS_DRV_WritePin(GPIO_PORTD,Right_Indicator,1);
PINS_DRV_WritePin(GPIO_PORTD, Left_Indicator,1);
delay (1000000);
PINS_DRV_WritePin(GPIO_PORTD,Right_Indicator,0);
PINS_DRV_WritePin(GPIO_PORTD,Left_Indicator, 0);
delay (1000000);
PINS_DRV_WritePin(GPIO_PORTD,Right_Indicator,1);
PINS_DRV_WritePin(GPIO_PORTD, Left_Indicator,1);
delay (1000000);
PINS_DRV_WritePin(GPIO_PORTD,Right_Indicator,0);
PINS_DRV_WritePin(GPIO_PORTD,Left_Indicator, 0);
//
// functionExecuted = true;
// }
}
void Vehicle_Switching_Operation(void)
{
if (Blankarray[6]==0x9D && Blankarray[7]==0x30 && Blankarray[8]==0x49 && Blankarray[9]==0x6B)
{
PINS_DRV_WritePin(GPIO_PORTB,Display_Ignition_Relay,1);//Sleep/wake Signal Cluster
delay(10000000);
PINS_DRV_WritePin(GPIO_PORTE,Cluster_Screen_Trig,1);
Steering_Unlock();
Indicator_Light_Start_Stop ();
SYSTEM_AUTH = 1;
SYSTEM_PARK = 1;
BATTERY_LOCKED = 1; //since VE4 is a fixed battery pack
// Reset array values to zero
Blankarray[6] = 0;
Blankarray[7] = 0;
Blankarray[8] = 0;
Blankarray[9] = 0;
}
Screen_Trigger_ON ();// this function allows to run the soft switches
CHARGING_OPERATION();// Charging operation
if (CHARGING == 0 && SYSTEM_PARK == 1 && (PTC->PDIR & (1<<8)) == 0)// RED KEY SWITCH ON
{
PINS_DRV_WritePin(GPIO_PORTE,Cluster_Screen_Trig,0);// Navigate to Home Page
PINS_DRV_WritePin(GPIO_PORTD,Discharge_Contactor,1);//since the battery is not removed it can directly be turned On
delay(100000);//delay required, so, power doesn't flow immediately after the contactor turned on
if (BATTERY_LOCKED ==1)
{
PINS_DRV_WritePin(GPIO_PORTC,Light_Sound_Relay,1);
SYSTEM_ON = 1;
SYSTEM_PARK = 0;
}
}
if (CHARGING == 0 && SYSTEM_ON==1 && (PTC->PDIR & (1<<9)) == 0) // Brake Pressed
{
if (SYSTEM_PARK == 0 && (PTA -> PDIR & (1<<7)) == 0) //Push Button 1 Pressed
{
PINS_DRV_WritePin(GPIO_PORTE,Motor_Park,1); //SONACOM M.CON START SEQ
SYSTEM_READY = 1;
}
}
if ( CHARGING == 0 && SYSTEM_ON==1 && SYSTEM_READY==1) // Throttle Enable
{
PINS_DRV_WritePin(GPIO_PORTB,Throttle_Relay,1);// enable this based on side stand
SYSTEM_MOVING = 1;
}
if (CHARGING == 0 && SYSTEM_ON == 1 && (PTC->PDIR & (1<<8)) !=0 ) // RED KEY SWITCH OFF
{
PINS_DRV_WritePin(GPIO_PORTC,Light_Sound_Relay,0);
PINS_DRV_WritePin(GPIO_PORTE,Motor_Park,0);
PINS_DRV_WritePin(GPIO_PORTB,Throttle_Relay,0);
PINS_DRV_WritePin(GPIO_PORTD,Discharge_Contactor,0);
PINS_DRV_WritePin(GPIO_PORTE,Cluster_Screen_Trig,1);
SYSTEM_ON = 0;
SYSTEM_READY = 0;
SYSTEM_MOVING = 0;
SYSTEM_PARK = 1;
}
if (CHARGING == 0 && SYSTEM_PARK == 1 && (PTA -> PDIR & (1<<7)) == 0) //Push Button 1 Pressed
{
PINS_DRV_WritePin(GPIO_PORTB,Display_Ignition_Relay,0);
Indicator_Light_Start_Stop ();
Steering_lock();
SYSTEM_PARK = 0;
SYSTEM_AUTH = 0;
}
}
void Monitoring_Vehicle_Input_Output(void)
{
// Kill Switch Monitoring
if ((PTC->PDIR & (1<<8)) == 0 ) //RED KEY SWITCH ON
{
Kill_Switch = 1;
Vehicle_STAT.data[0] |= (1<<0); //set bit 0
}
else
{
Kill_Switch = 0;
Vehicle_STAT.data[0] &= ~(1<<0); //clear bit 0
}
// Push Button Monitoring
if ((PTA->PDIR & (1<<7)) == 0 ) //Push Button ON
{
Push_Button = 1;
Vehicle_STAT.data[0] |= (1<<1); //set bit 1
}
else
{
Push_Button = 0;
Vehicle_STAT.data[0] &= ~(1<<1); //clear bit 1
}
// Brake Monitoring
if ((PTC->PDIR & (1<<9)) == 0 ) //Brake Pressed
{
Brake = 1;//Brake Pressed
Vehicle_STAT.data[0] |= (1<<2); //set bit 2
}
else
{
Brake = 0;
Vehicle_STAT.data[0] &= ~(1<<2); //Clear bit 2
}
// Side Stand
if ((PTE->PDIR & (1<<5)) == 0 ) //Side Stand Enable // Enable this as a condition to turn the throttle realy on and off
{
Side_Stand = 1;// cut of the throttle
Vehicle_STAT.data[1] |= (1<<4); //Set bit 4
Vehicle_STAT.data[1] &= ~(1<<5); //Clear bit 5
}
else if ((PTE->PDIR & (1<<5)) != 0 ) // Side Stand Disabled
{
Side_Stand = 0;//connect the throttle
Vehicle_STAT.data[1] &= ~ (1<<4); //Clear bit 4
Vehicle_STAT.data[1] &= ~ (1<<5); //Clear bit 5
}
else
{
Side_Stand = 2;// connecet the throttle so that the malfunction of side stand doesn't effectt the throttle functioning
Vehicle_STAT.data[1] &= ~ (1<<4); //Clear bit 4
Vehicle_STAT.data[1] |= (1<<5); //Set bit 5
}
//Steering Lock
if (((PTE->PDIR & (1<<4)) != 0) && ((PTE->PDIR & (1<<3)) == 0)) // Feedback1 0v and Feedback2 12V
{
Steering_Lock_STAT = 1; //Unlocked (Traveled In)
Vehicle_STAT.data[1] |= (1<<0); //Set bit 0
Vehicle_STAT.data[1] &= ~(1<<1); //Clear bit 1
}
else if (((PTE->PDIR & (1<<4)) == 0) && ((PTE->PDIR & (1<<3)) != 0)) // Feedback1 12v and Feedback2 0V
{
Steering_Lock_STAT = 0; //Locked (Traveled Out)
Vehicle_STAT.data[1] &= ~(1<<0); //Clear bit 0
Vehicle_STAT.data[1] &= ~(1<<1); //Clear bit 1
}
else
{
Steering_Lock_STAT = 2; // Lock Error (Stuck in between)
Vehicle_STAT.data[1] &= ~(1<<0); //Clear bit 0
Vehicle_STAT.data[1] |= (1<<1); //Set bit 1
}
// Charging Status - Byte 2 (Bit 0)
if(CHARGING == 1)
{
Vehicle_STAT.data[2] |= (1 << 0); //Set bit 0; 1-Charging
}
else
{
Vehicle_STAT.data[2] &= ~(1 << 0); //clear bit 0; 0-Not Charging
}
}
void Monitoring_Vehicle_CAN(void)
{
//Vehicle CAN data Monitoring of all nodes
CAN_Send (INST_CAN_PAL2, Vehicle_STAT_MAILBOX_7, &Vehicle_STAT);
CAN_Send (INST_CAN_PAL2, Vehicle_SUBSYS_STAT_MAILBOX_8, &Vehicle_SUBSYS_STAT);
}
int main(void)
{
/*** Processor Expert internal initialization. DON'T REMOVE THIS CODE!!! ***/
#ifdef PEX_RTOS_INIT
PEX_RTOS_INIT(); /* Initialization of the selected RTOS. Macro is defined by the RTOS component. */
#endif
/*** End of Processor Expert internal initialization. ***/
BoardInit();
//RFID LPUART Initialization
LPUART_DRV_Init(INST_LPUART_RFID, &lpuart_rfid_State, &lpuart_rfid_InitConfig0);
delay (10000);
// CAN Initialization+
CAN_Init(INST_CAN_PAL1,&can_pal1_Config0);
CAN_Init(INST_CAN_PAL2,&can_pal2_Config0);
//CAN Buffer Configuration for CAN PAL1 and CAN_PAL2
can_buff_config_t stdbuff = {
.enableFD = true,
.enableBRS = true,
.idType = CAN_MSG_ID_STD
};
//Configure Tx Buffer with Tx_Mailbox for CAN_PAL1
CAN_ConfigTxBuff(INST_CAN_PAL1, TX1VOLTAGE_MAILBOX_1, &stdbuff);
CAN_ConfigTxBuff(INST_CAN_PAL1, TX1SOC_MAILBOX_2, &stdbuff);
CAN_ConfigTxBuff(INST_CAN_PAL1, TX1STATUS_MAILBOX_3, &stdbuff);
CAN_ConfigTxBuff(INST_CAN_PAL1, TX1TEMP1_MAILBOX_4, &stdbuff);
CAN_ConfigTxBuff(INST_CAN_PAL1, TX1TEMP2_MAILBOX_5, &stdbuff);
//Configure Rx Buffer with Rx_mailbox for CAN_PAL1
CAN_ConfigRxBuff(INST_CAN_PAL1, RX1VOLTAGE_MAILBOX_1, &stdbuff, RX1VOLTAGE_ID1);
CAN_ConfigRxBuff(INST_CAN_PAL1, RX1SOC_MAILBOX_2, &stdbuff, RX1SOC_ID2);
CAN_ConfigRxBuff(INST_CAN_PAL1, RX1STATUS_MAILBOX_3, &stdbuff, RX1STATUS_ID3);
CAN_ConfigRxBuff(INST_CAN_PAL1, RX1TEMP1_MAILBOX_4, &stdbuff, RX1TEMP1_ID4);
CAN_ConfigRxBuff(INST_CAN_PAL1, RX1TEMP2_MAILBOX_5, &stdbuff, RX1TEMP2_ID5);
//Configure Tx Buffer with Tx_Mailbox for CAN_PAL2
CAN_ConfigTxBuff(INST_CAN_PAL2, TX2VOLTAGE_MAILBOX_1, &stdbuff);
CAN_ConfigTxBuff(INST_CAN_PAL2, TX2SOC_MAILBOX_2, &stdbuff);
CAN_ConfigTxBuff(INST_CAN_PAL2, TX2STATUS_MAILBOX_3, &stdbuff);
CAN_ConfigTxBuff(INST_CAN_PAL2, TX2TEMP1_MAILBOX_4, &stdbuff);
CAN_ConfigTxBuff(INST_CAN_PAL2, TX2TEMP2_MAILBOX_5, &stdbuff);
CAN_ConfigTxBuff(INST_CAN_PAL2, TX2stefen_SOC_MAILBOX_6, &stdbuff);
CAN_ConfigTxBuff(INST_CAN_PAL2, Vehicle_STAT_MAILBOX_7, &stdbuff);
CAN_ConfigTxBuff(INST_CAN_PAL2, Vehicle_SUBSYS_STAT_MAILBOX_8, &stdbuff);
// Define messages in TX1 send buffer
can_message_t TX1VOLTAGE = {
.cs = 0U,
.id = TX1VOLTAGE_ID1,
.data[0] = 0x5A,.data[1] = 00,.data[2] = 00,.data[3] = 00,.data[4] = 00,.data[5] = 00,.data[6] = 00,.data[7] = 00,
.length = 8U
};
can_message_t TX1SOC = {
.cs = 0U,
.id = TX1SOC_ID2,
.data[0] = 0x5A,.data[1] = 00,.data[2] = 00,.data[3] = 00,.data[4] = 00,.data[5] = 00,.data[6] = 00,.data[7] = 00,
.length = 8U
};
can_message_t TX1STATUS = {
.cs = 0U,
.id = TX1STATUS_ID3,
.data[0] = 0x5A,.data[1] = 00,.data[2] = 00,.data[3] = 00,.data[4] = 00,.data[5] = 00,.data[6] = 00,.data[7] = 00,
.length = 8U
};
can_message_t TX1TEMP1 = {
.cs = 0U,
.id = TX1TEMP1_ID4,
.data[0] = 0x5A,.data[1] = 00,.data[2] = 00,.data[3] = 00,.data[4] = 00,.data[5] = 00,.data[6] = 00,.data[7] = 00,
.length = 8U
};
can_message_t TX1TEMP2 = {
.cs = 0U,
.id = TX1TEMP2_ID5,
.data[0] = 0x5A,.data[1] = 00,.data[2] = 00,.data[3] = 00,.data[4] = 00,.data[5] = 00,.data[6] = 00,.data[7] = 00,
.length = 8U
};
//Setup and Initialization for Receiving the CAN messages
can_message_t RX1VOLTAGE;
can_message_t RX1SOC;
can_message_t RX1STATUS;
can_message_t RX1TEMP1;
can_message_t RX1TEMP2;
while (1)
{
// LPUART Send and Receive loop setup
LPUART_DRV_SendDataBlocking(INST_LPUART_RFID,Inventory_cmd,5, Timeout);
LPUART_DRV_ReceiveDataBlocking(INST_LPUART_RFID,Blankarray,20, Timeout);
// Vehicle Switching Operation flow.
Vehicle_Switching_Operation();
// Vehicle Input and Output Monitoring constant updates of the vehicle STAT
Monitoring_Vehicle_Input_Output();
// Vehicle CAN Monitoring and Notification Trigger, send the updated data
//Monitoring_Vehicle_CAN();
//Transmitt the TX1 frames
delay(10000);
if (CAN_Send(INST_CAN_PAL1, TX1VOLTAGE_MAILBOX_1, &TX1VOLTAGE) == STATUS_SUCCESS)
{
arrayindex++;
}
delay(10000);
if (CAN_Send(INST_CAN_PAL1, TX1SOC_MAILBOX_2, &TX1SOC) == STATUS_SUCCESS)
{
arrayindex++;
}
delay(10000);
if (CAN_Send(INST_CAN_PAL1, TX1STATUS_MAILBOX_3, &TX1STATUS) == STATUS_SUCCESS)
{
arrayindex++;
}
delay(10000);
if (CAN_Send(INST_CAN_PAL1, TX1TEMP1_MAILBOX_4, &TX1TEMP1) == STATUS_SUCCESS)
{
arrayindex++;
}
delay(10000);
if (CAN_Send(INST_CAN_PAL1, TX1TEMP2_MAILBOX_5, &TX1TEMP2) == STATUS_SUCCESS)
{
arrayindex++;
}
//Receiving the RX1 frames
if (CAN_Receive(INST_CAN_PAL1, RX1VOLTAGE_MAILBOX_1, &RX1VOLTAGE) == STATUS_SUCCESS)
{
micronix_voltage = ((uint16_t)RX1VOLTAGE.data[0]<<8) | (uint16_t)RX1VOLTAGE.data[1];//Big Endian mapping
//micronix_voltage = ((uint16_t)RX1VOLTAGE.data[1]<<8) | (uint16_t)RX1VOLTAGE.data[0];//Little Endian mapping
stefen_voltage = micronix_voltage/10;
arrayindex1++;
}
if (CAN_Receive(INST_CAN_PAL1, RX1SOC_MAILBOX_2, &RX1SOC) == STATUS_SUCCESS)
{
stefen_SOC = RX1SOC.data[5] *10;
arrayindex1++;
}
if (CAN_Receive(INST_CAN_PAL1, RX1STATUS_MAILBOX_3, &RX1STATUS) == STATUS_SUCCESS)
{
arrayindex1++;
}
if (CAN_Receive(INST_CAN_PAL1, RX1TEMP1_MAILBOX_4, &RX1TEMP1) == STATUS_SUCCESS)
{
arrayindex1++;
}
if (CAN_Receive(INST_CAN_PAL1, RX1TEMP2_MAILBOX_5, &RX1TEMP2) == STATUS_SUCCESS)
{
arrayindex1++;
}
// Set up for the TX2 Message with the shifted Payloads from RX1 Message
can_message_t TX2VOLTAGE = {
.cs = 0U,
.id = TX2VOLTAGE_ID1,
.data[0] = RX1VOLTAGE.data[0],
.data[1] = RX1VOLTAGE.data[1],
.data[2] = RX1VOLTAGE.data[2],
.data[3] = RX1VOLTAGE.data[3],
.data[4] = RX1VOLTAGE.data[4],
.data[5] = RX1VOLTAGE.data[5],
.data[6] = RX1VOLTAGE.data[6],
.data[7] = RX1VOLTAGE.data[7],
.length = 8U
};
can_message_t TX2SOC = {
.cs = 0U,
.id = TX2SOC_ID2,
.data[0] = RX1SOC.data[0],
.data[1] = RX1SOC.data[1],
.data[2] = RX1SOC.data[2],
.data[3] = RX1SOC.data[3],
.data[4] = RX1SOC.data[4],
.data[5] = RX1SOC.data[5],
.data[6] = RX1SOC.data[6],
.data[7] = RX1SOC.data[7],
.length = 8U
};
can_message_t TX2STATUS = {
.cs = 0U,
.id = TX2STATUS_ID3,
.data[0] = RX1STATUS.data[0],
.data[1] = RX1STATUS.data[1],
.data[2] = RX1STATUS.data[2],
.data[3] = RX1STATUS.data[3],
.data[4] = RX1STATUS.data[4],
.data[5] = RX1STATUS.data[5],
.data[6] = RX1STATUS.data[6],
.data[7] = RX1STATUS.data[7],
.length = 8U
};
can_message_t TX2TEMP1 = {
.cs = 0U,
.id = TX2TEMP1_ID4,
.data[0] = RX1TEMP1.data[0],
.data[1] = RX1TEMP1.data[1],
.data[2] = RX1TEMP1.data[2],
.data[3] = RX1TEMP1.data[3],
.data[4] = RX1TEMP1.data[4],
.data[5] = RX1TEMP1.data[5],
.data[6] = RX1TEMP1.data[6],
.data[7] = RX1TEMP1.data[7],
.length = 8U
};
can_message_t TX2TEMP2 = {
.cs = 0U,
.id = TX2TEMP2_ID5,
.data[0] = RX1TEMP2.data[0],
.data[1] = RX1TEMP2.data[1],
.data[2] = RX1TEMP2.data[2],
.data[3] = RX1TEMP2.data[3],
.data[4] = RX1TEMP2.data[4],
.data[5] = RX1TEMP2.data[5],
.data[6] = RX1TEMP2.data[6],
.data[7] = RX1TEMP2.data[7],
.length = 8U
};
can_message_t TX2stefen_SOC = {
.cs = 0U,
.id = TX2stefen_SOC_ID6,
.data[0] = TX2stefen_SOC.data[0],
.data[1] = TX2stefen_SOC.data[1],
.data[2] = TX2stefen_SOC.data[0],
.data[3] = TX2stefen_SOC.data[1],
.data[4] = 0,
.data[5] = 0,
.data[6] = TX2stefen_SOC.data[6],
.data[7] = TX2stefen_SOC.data[7],
.length = 8U
};
// mapping the Micronix SOC data to stefen SOC
TX2stefen_SOC.data[6] = (uint8_t)(stefen_SOC&0xFF); // TX2stefen_SOC.data[6] stores the least significant byte (LSB) of stefen_SOC.
//This is done using (stefen_SOC & 0xFF) to isolate the LSB.
TX2stefen_SOC.data[7] = (uint8_t)((stefen_SOC>>8)&0xFF);
// mapping the micronix voltage data to stefen voltage
TX2stefen_SOC.data[0] = (uint8_t)(stefen_voltage&0xFF);
TX2stefen_SOC.data[1] = (uint8_t)((stefen_voltage>>8)&0xFF);
// Switch Case Conditions for Tx the Std BMS Data over CAN PAL 2
switch (RX1VOLTAGE.id)
{
case 0x100: //CAN
delay (1000);
CAN_Send (INST_CAN_PAL2,TX2VOLTAGE_MAILBOX_1, &TX2VOLTAGE);
arrayindex2++;
//if (CAN_Send (INST_CAN_PAL2,TX2VOLTAGE_MAILBOX_1, &TX2VOLTAGE) == STATUS_SUCCESS)
//{
//LPUART1_transmit_string("\r\n 0x310 Transmitted \r\n");
//}
break;
default:
break;
}
switch (RX1SOC.id)
{
case 0x101: //CAN
delay (1000);
CAN_Send (INST_CAN_PAL2,TX2SOC_MAILBOX_2, &TX2SOC);
CAN_Send (INST_CAN_PAL2,TX2stefen_SOC_MAILBOX_6, &TX2stefen_SOC);
arrayindex2++;
break;
default:
break;
}
switch (RX1STATUS.id)
{
case 0x102: //CAN
delay (1000);
CAN_Send (INST_CAN_PAL2,TX2STATUS_MAILBOX_3, &TX2STATUS);
arrayindex2++;
break;
default:
break;
}
switch (RX1TEMP1.id)
{
case 0x105: //CAN
delay (1000);
CAN_Send (INST_CAN_PAL2,TX2TEMP1_MAILBOX_4, &TX2TEMP1);
arrayindex2++;
break;
default:
break;
}
switch (RX1TEMP2.id)
{
case 0x106: //CAN
delay (1000);
CAN_Send (INST_CAN_PAL2,TX2TEMP2_MAILBOX_5, &TX2TEMP2);
arrayindex2++;
break;
default:
break;
}
}
/*** Don't write any code pass this line, or it will be deleted during code generation. ***/
/*** RTOS startup code. Macro PEX_RTOS_START is defined by the RTOS component. DON'T MODIFY THIS CODE!!! ***/
#ifdef PEX_RTOS_START
PEX_RTOS_START(); /* Startup of the selected RTOS. Macro is defined by the RTOS component. */
#endif
/*** End of RTOS startup code. ***/
/*** Processor Expert end of main routine. DON'T MODIFY THIS CODE!!! ***/
for(;;) {
if(exit_code != 0) {
break;
}
}
return exit_code;
/*** Processor Expert end of main routine. DON'T WRITE CODE BELOW!!! ***/
} /*** End of main routine. DO NOT MODIFY THIS TEXT!!! ***/
/* END main */
/*!
** @}
*/
/*
** ###################################################################
**
** This file was created by Processor Expert 10.1 [05.21]
** for the Freescale S32K series of microcontrollers.
**
** ###################################################################
*/
P.S: I have extracted the Issue summary by a Claude AI generative AI after step by step interaction with it during my debug process inorder to have quick summary. Please comment to this post if any additional info is required inroder to rectifyu the issue. But i have proof read this thoroughly
CAN Transmission Issue Brief Report
Problem Summary
Experiencing a CAN transmission anomaly on your S32K146 VCU where the software indicates successful CAN frame transmission (arrayindex2 increments, CAN_Send() returns success), but no CAN frames are visible on external CAN analyzer despite the hardware and basic transmission logic working correctly.
System Architecture
Based on your schematic:
Debugging Steps Performed
1. Hardware Verification
2. Successful Test Scenarios
3. Switch Case Logic Verification
Your main application code processes received CAN frames from BMS (via CAN PAL 1) and retransmits via CAN PAL 2:
4. Debug Log Analysis
Console logs show:
5. Priority Analysis Verification
Message ID priorities confirmed:
6. Isolation Testing Results
Motor Controller disconnected test:
7. Analyzer Validation
CAN analyzer functionality confirmed:
Critical Findings
1. Software Logic Confirmed Working
The arrayindex2 increment pattern definitively proves:
2. Hardware Functionality Verified
3. Priority Not the Issue
With Motor Controller using 0x500-0x5FF range and VCU using 0x100-0x310 range, arbitration heavily favors VCU frames. This is confirmed by Motor Controller disconnected test showing same symptoms.
Current Issue Analysis
The evidence points to a CAN frame acknowledgment (ACK) problem specific to your main application. The S32K FlexCAN controller successfully executes transmission commands and increments software counters, but the frames are not being acknowledged properly, causing them to never complete the full CAN protocol cycle.
Key Insight: ACK Requirement
Every CAN frame requires acknowledgment from at least one receiving device. In your setup:
I would appriciate some help here.
P.S: I have extracted the Issue summary by a Claude AI generative AI after step by step interaction with it during my debug process inorder to have quick summary. Please comment to this post if any additional info is required inroder to rectifyu the issue
Hi @akhilranga,
If I understood your post correctly, you have tested both CAN0 and CAN1 for S32K146 in simple projects, and both work correctly.
However, you are not seeing any data on the CAN analyzer (connected to CAN PAL 2). Added to this, you mentioned that there are terminating resistors on both nodes, and the SW returns a successful call for CAN transmission.
Are you able to scope the bus with an oscilloscope for any activity on the bus? Is the line continuously pulled low?
I understand you tested transmission in a simple project, which probably means the error comes from implementation in your application. I can see from your code that the buffers are configured for CAN-FD and with BRS on. Please confirm if both nodes are configured for CAN-FD and same bitrate + sampling point.
Could you please share a simple project where the behavior can be observed? Please keep in mind that custom implementation is out of scope for the support of this community.
Best regards,
Julián
These are the configuration settings of the CAN PAL1 and CAN PAL 2 of the main project where the CAN issue is being noticed. Is this what you wanted me to confirm for both the nodes.
And follow up to this i will be adding the sample project code below where the data was seen successfully transmitted.
/*
* Copyright (c) 2015 - 2016 , Freescale Semiconductor, Inc.
* Copyright 2016-2017 NXP
* All rights reserved.
*
* THIS SOFTWARE IS PROVIDED BY NXP "AS IS" AND ANY EXPRESSED OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL NXP OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
* THE POSSIBILITY OF SUCH DAMAGE.
*/
/* Including needed modules to compile this module/procedure */
#include "Cpu.h"
#include "clockMan1.h"
#include "pin_mux.h"
#if CPU_INIT_CONFIG
#include "Init_Config.h"
#endif
volatile int exit_code = 0;
/* User includes (#include below this line is not maintained by Processor Expert) */
#include <stdint.h>
#include <stdbool.h>
/* This example is setup to work by default with EVB. To use it with other boards
please comment the following line
*/
//CAN Rx Frame ID and MAILBOX Setup for CAN_PAL1
#define RX1_MAILBOX_1 (6UL)
#define RX1_ID1 (0x211)
#define RX1_MAILBOX_2 (7UL)
#define RX1_ID2 (0x212)
#define RX1_MAILBOX_3 (8UL)
#define RX1_ID3 (0x213)
//CAN Tx Frame ID and MAILBOX Setup for CAN_PAL1
#define TX1_MAILBOX_1 (4UL)
#define TX1_ID1 (0x211)
#define TX1_MAILBOX_2 (5UL)
#define TX1_ID2 (0x212)
#define TX1_MAILBOX_3 (6UL)
#define TX1_ID3 (0x213)
//CAN Rx Frame ID and MAILBOX Setup for CAN_PAL2
#define RX2_MAILBOX_1 (7UL)
#define RX2_ID1 (0x214)
#define RX2_MAILBOX_2 (8UL)
#define RX2_ID2 (0x215)
#define RX2_MAILBOX_3 (9UL)
#define RX2_ID3 (0x216)
//CAN Tx Frame ID and MAILBOX Setup for CAN_PAL2
#define TX2_MAILBOX_1 (1UL)
#define TX2_ID1 (0x214)
#define TX2_MAILBOX_2 (2UL)
#define TX2_ID2 (0x215)
#define TX2_MAILBOX_3 (3UL)
#define TX2_ID3 (0x216)
uint8_t arrayindex = 0 ;
uint8_t arrayindex1 = 0;
uint8_t Motor_CAN_Receive =0;
void delay(volatile int cycles)
{
/* Delay function - do nothing for a number of cycles */
while(cycles--);
}
void BoardInit(void)
{
/* Initialize and configure clocks
* - Setup system clocks, dividers
* - Configure FlexCAN clock, GPIO, LPSPI
* - see clock manager component for more details
*/
CLOCK_SYS_Init(g_clockManConfigsArr, CLOCK_MANAGER_CONFIG_CNT,
g_clockManCallbacksArr, CLOCK_MANAGER_CALLBACK_CNT);
CLOCK_SYS_UpdateConfiguration(0U, CLOCK_MANAGER_POLICY_FORCIBLE);
/* Initialize pins
* - Init FlexCAN, LPSPI and GPIO pins
* - See PinSettings component for more info
*/
PINS_DRV_Init(NUM_OF_CONFIGURED_PINS, g_pin_mux_InitConfigArr);
}
int main(void)
{
/*** Processor Expert internal initialization. DON'T REMOVE THIS CODE!!! ***/
#ifdef PEX_RTOS_INIT
PEX_RTOS_INIT(); /* Initialization of the selected RTOS. Macro is defined by the RTOS component. */
#endif
/*** End of Processor Expert internal initialization. ***/
BoardInit();
// CAN Initialization+
CAN_Init(INST_CAN_PAL1,&can_pal1_Config0);
CAN_Init(INST_CAN_PAL2,&can_pal2_Config0);
//CAN Buffer Configuration for CAN PAL1 and CAN_PAL2
can_buff_config_t stdbuff = {
.enableFD = true,
.enableBRS = true,
.idType = CAN_MSG_ID_STD
};
//Configure Rx Buffer with Rx_mailbox for CAN_PAL1
CAN_ConfigRxBuff(INST_CAN_PAL1, RX1_MAILBOX_1, &stdbuff, RX1_ID1);
CAN_ConfigRxBuff(INST_CAN_PAL1, RX1_MAILBOX_2, &stdbuff, RX1_ID2);
CAN_ConfigRxBuff(INST_CAN_PAL1, RX1_MAILBOX_3, &stdbuff, RX1_ID3);
//Configure Tx Buffer with Tx_Mailbox for CAN_PAL2
CAN_ConfigTxBuff(INST_CAN_PAL2, TX1_MAILBOX_1, &stdbuff);
CAN_ConfigTxBuff(INST_CAN_PAL2, TX1_MAILBOX_2, &stdbuff);
CAN_ConfigTxBuff(INST_CAN_PAL2, TX1_MAILBOX_3, &stdbuff);
//Configure Rx Buffer with Rx_mailbox for CAN_PAL2
CAN_ConfigRxBuff(INST_CAN_PAL2, RX2_MAILBOX_1, &stdbuff, RX2_ID1);
CAN_ConfigRxBuff(INST_CAN_PAL2, RX2_MAILBOX_2, &stdbuff, RX2_ID2);
CAN_ConfigRxBuff(INST_CAN_PAL2, RX2_MAILBOX_3, &stdbuff, RX2_ID3);
//Configure Tx Buffer with Tx_Mailbox for CAN_PAL1
CAN_ConfigTxBuff(INST_CAN_PAL1, TX2_MAILBOX_1, &stdbuff);
CAN_ConfigTxBuff(INST_CAN_PAL1, TX2_MAILBOX_2, &stdbuff);
CAN_ConfigTxBuff(INST_CAN_PAL1, TX2_MAILBOX_3, &stdbuff);
//Setup and Initialization for Receiving the CAN messages
can_message_t RX1ID1;
can_message_t RX1ID2;
can_message_t RX1ID3;
can_message_t RX2ID1;
can_message_t RX2ID2;
can_message_t RX2ID3;
while (1)
{
// RX from the CAN Analyzer on CAN PAL 1 (CAN 1) andTx from CAN PAL 1 (CAN 0) to CAN PAL 2 (CAN 2)
// Send 0x211; 0x212; 0x213; from CAN Analyzer
//Connect the Analyzer on CAN PAL 1 instance and send the data 0x211; 0x212; 0x213 and
//connect other analyzer on the CAN PAL 2 Instance and receive the data 0x211; 0x212; 0x213
//Receiving the RX1 frames
if (CAN_Receive(INST_CAN_PAL1, RX1_MAILBOX_1, &RX1ID1) == STATUS_SUCCESS)
{
arrayindex++;
}
if (CAN_Receive(INST_CAN_PAL1, RX1_MAILBOX_2, &RX1ID2) == STATUS_SUCCESS)
{
arrayindex++;
}
if (CAN_Receive(INST_CAN_PAL1, RX1_MAILBOX_3, &RX1ID3) == STATUS_SUCCESS)
{
arrayindex++;
}
//CAN PAL 2 TX1 Msg frames Structure mappinng from RX1 Msg frames
can_message_t TX1ID1 = {
.cs = 0U,
.id = TX1_ID1,
.data[0] = RX1ID1.data[0],
.data[1] = RX1ID1.data[1],
.data[2] = RX1ID1.data[2],
.data[3] = RX1ID1.data[3],
.data[4] = RX1ID1.data[4],
.data[5] = RX1ID1.data[5],
.data[6] = RX1ID1.data[6],
.data[7] = RX1ID1.data[7],
.length = 8U
};
can_message_t TX1ID2 = {
.cs = 0U,
.id = TX1_ID2,
.data[0] = RX1ID2.data[0],
.data[1] = RX1ID2.data[1],
.data[2] = RX1ID2.data[2],
.data[3] = RX1ID2.data[3],
.data[4] = RX1ID2.data[4],
.data[5] = RX1ID2.data[5],
.data[6] = RX1ID2.data[6],
.data[7] = RX1ID2.data[7],
.length = 8U
};
can_message_t TX1ID3 = {
.cs = 0U,
.id = TX1_ID3,
.data[0] = RX1ID3.data[0],
.data[1] = RX1ID3.data[1],
.data[2] = RX1ID3.data[2],
.data[3] = RX1ID3.data[3],
.data[4] = RX1ID3.data[4],
.data[5] = RX1ID3.data[5],
.data[6] = RX1ID3.data[6],
.data[7] = RX1ID3.data[7],
.length = 8U
};
//Transmitt the TX1 frames
switch (RX1ID1.id)
{
case 0x211: //CAN
CAN_Send(INST_CAN_PAL2, TX1_MAILBOX_1,&TX1ID1);
arrayindex1++;
break;
default:
break;
}
switch (RX1ID1.id)
{
case 0x211: //CAN
CAN_Send(INST_CAN_PAL2, TX1_MAILBOX_2, &TX1ID2);
arrayindex1++;
break;
default:
break;
}
switch (RX1ID1.id)
{
case 0x211: //CAN
CAN_Send(INST_CAN_PAL2, TX1_MAILBOX_3, &TX1ID3);
arrayindex1++;
break;
default:
break;
}
// RX from the CAN Analyzer on CAN PAL 2 (CAN 2) and Tx from CAN PAL 2 (CAN 2) to CAN PAL 1 (CAN 0)
// Send 0x214; 0x215; 0x216; from CAN Analyzer
//Connect the Analyzer on CAN PAL 2 instance and send the data 0x214; 0x215; 0x216; and
//connect other analyzer on the CAN PAL 1 Instance and receive the data 0x214; 0x215; 0x216;
//Receiving the RX2 frames
//
// if (CAN_Receive(INST_CAN_PAL2, RX2_MAILBOX_1, &RX2ID1) == STATUS_SUCCESS)
// {
// arrayindex++;
// }
//
// if (CAN_Receive(INST_CAN_PAL2, RX2_MAILBOX_2, &RX2ID2) == STATUS_SUCCESS)
// {
// arrayindex++;
// }
//
//
// if (CAN_Receive(INST_CAN_PAL2, RX2_MAILBOX_3, &RX2ID3) == STATUS_SUCCESS)
// {
// arrayindex++;
// }
//
// //CAN PAL 2 TX1 Msg frames Structure mappinng from RX1 Msg frames
//
// can_message_t TX2ID1 = {
// .cs = 0U,
// .id = TX2_ID1,
// .data[0] = RX2ID1.data[0],
// .data[1] = RX2ID1.data[1],
// .data[2] = RX2ID1.data[2],
// .data[3] = RX2ID1.data[3],
// .data[4] = RX2ID1.data[4],
// .data[5] = RX2ID1.data[5],
// .data[6] = RX2ID1.data[6],
// .data[7] = RX2ID1.data[7],
// .length = 8U
// };
//
//
// can_message_t TX2ID2 = {
// .cs = 0U,
// .id = TX2_ID2,
// .data[0] = RX2ID2.data[0],
// .data[1] = RX2ID2.data[1],
// .data[2] = RX2ID2.data[2],
// .data[3] = RX2ID2.data[3],
// .data[4] = RX2ID2.data[4],
// .data[5] = RX2ID2.data[5],
// .data[6] = RX2ID2.data[6],
// .data[7] = RX2ID2.data[7],
// .length = 8U
// };
//
//
// can_message_t TX2ID3 = {
// .cs = 0U,
// .id = TX2_ID3,
// .data[0] = RX2ID3.data[0],
// .data[1] = RX2ID3.data[1],
// .data[2] = RX2ID3.data[2],
// .data[3] = RX2ID3.data[3],
// .data[4] = RX2ID3.data[4],
// .data[5] = RX2ID3.data[5],
// .data[6] = RX2ID3.data[6],
// .data[7] = RX2ID3.data[7],
// .length = 8U
// };
//
//
//
//
//
// //Transmitt the TX1 frames
//
//
//switch (RX2ID1.id)
// {
// case 0x214: //CAN
//
// CAN_Send(INST_CAN_PAL1, TX2_MAILBOX_1, &TX2ID1);
// arrayindex1++;
//
// break;
//
// default:
// break;
//
// }
//
//switch (RX2ID2.id)
// {
// case 0x215: //CAN
//
// CAN_Send(INST_CAN_PAL1, TX2_MAILBOX_2, &TX2ID2);
// arrayindex1++;
//
// break;
//
// default:
// break;
//
// }
//
//switch (RX2ID3.id)
// {
// case 0x216: //CAN
//
// CAN_Send(INST_CAN_PAL1, TX2_MAILBOX_3, &TX2ID3);
// arrayindex1++;
//
// break;
//
// default:
// break;
//
// }
}
/*** Don't write any code pass this line, or it will be deleted during code generation. ***/
/*** RTOS startup code. Macro PEX_RTOS_START is defined by the RTOS component. DON'T MODIFY THIS CODE!!! ***/
#ifdef PEX_RTOS_START
PEX_RTOS_START(); /* Startup of the selected RTOS. Macro is defined by the RTOS component. */
#endif
/*** End of RTOS startup code. ***/
/*** Processor Expert end of main routine. DON'T MODIFY THIS CODE!!! ***/
for(;;) {
if(exit_code != 0) {
break;
}
}
return exit_code;
/*** Processor Expert end of main routine. DON'T WRITE CODE BELOW!!! ***/
} /*** End of main routine. DO NOT MODIFY THIS TEXT!!! ***/
/* END main */
/*!
** @}
*/
/*
** ###################################################################
**
** This file was created by Processor Expert 10.1 [05.21]
** for the Freescale S32K series of microcontrollers.
**
** ###################################################################
*/the below are the CAN Nodes settings for the Test Project where the scucessful transmission is observed
P.S : I understand the limtations for support for the custoum implimentation. And i really appriciate your help. This is just a technical enquiry and trying to gain knowledge on what is that i am doing wrong. Just wanted another set of hands to assess this issue for me. Thank You
Hi @akhilranga,
Sorry for the late reply.
Looking at your CAN configuration between projects, it is exactly the same, correct?
How exactly are you testing communication? Going over the first code snippet you've shared, you have, Monitoring_Vehicle_CAN() function commented, meaning If there’s no RX traffic on CAN0, you’ll never see CAN2.
Since configuration is the same, and the issue probably comes from main routine; if you have already a working project, my suggestion is to build from it your application project.
Best regards,
Julián