J1939 Documentation
Version 4.16.00
Loading...
Searching...
No Matches
Initialisation Process

The J1939 protocol stack is initialized with J1939_MgrInit(). This routine will setup the CAN controller and initialize all necessary services. Afterwards the stack can be started by calling the J1939_MgrStart() function.

In summary four steps are necessary to run the J1939 protocol stack:

The initialization functions of the J1939 protocol stack have to be executed prior to any other API functions.

Initialization of J1939 protocol stack

void MyJ1939_Init(void)
{
//-----------------------------------------------------------------------------------------
// Initialize the J1939 protocol stack:
// Assign logical J1939 net 1 to physical CAN interface 1, use ECU address 2
//
//-----------------------------------------------------------------------------------------
// Add a PGN list to the logical network 1, use ECU1 PGN list in this example
//
//-----------------------------------------------------------------------------------------
// Start the J1939 protocol stack
//
//-----------------------------------------------------------------------------------------
// Now the J1939 protocol stack is started and has to be triggered by calling
// J1939_TmrEvent() with a cycle time of J1939_TIMER_PERIOD.
// We initialize the timer resource on the target CPU and call J1939_TmrEvent() with an
// update rate of 1 ms here
//
}
@ eCP_CHANNEL_1
Definition canpie.h:732
#define J1939_CONF_BITRATE_250K
Definition j1939_mgr.h:79
@ eJ1939_NET_1
Definition j1939_defs.h:117
J1939_PGN_Entry_ts atsPgnListEcu1[]
J1939_Status_tv J1939_MgrInit(uint8_t ubCanIfV, uint8_t ubNetV, uint8_t ubAddressV, uint16_t uwConfigV)
J1939_Status_tv J1939_MgrStart(uint8_t ubNetV)
J1939_Status_tv J1939_PgnAddList(uint8_t ubNetV, J1939_PGN_Entry_ts *ptsPgnListV)
void J1939_TmrEvent(void)
Execute Timer-based Services.
@ eTMR_CTRL_START
Definition mc_tmr.h:164
void McTmrInit(void)
Initialise Timer.
Status_tv McTmrFunctionInit(TmrHandler_fn fnHandlerV, uint32_t ulTicksV, uint8_t ubControlV)
Initialise function timer.
uint32_t McTmrTimeToTicks(uint32_t ulTimeV)
Convert time value to ticks.

After calling J1939_MgrStart() the J1939 Protocol Stack is running and an Address Claiming Message (ACM) is send on the CAN bus (i.e. the identifier 18EEFF00h + ECU-address).