CANopen Slave Documentation
Version 6.16.04
Loading...
Searching...
No Matches
Setting PDO communication parameter

During initialization of the PDO module the function CosPdoComSetup() is called. Within this function, any default PDO communication parameter can be modified by the application.

For that purpose, the application has access to the structure CosPdoCom_s for Receive PDOs (atsRcvPdoComG[]) and Transmit PDOs (atsTrmPdoComG).

Modifying the transmission type

The transmission type is modified the setting the element CosPdoCom_s::ubTransType with a value from the enumeration PdoType_e.

void CosPdoComSetup(void)
{
// .. other code
//------------------------------------------------------------------------------------
// set Transmit PDO 1 to cyclic, every SYNC message
//
//------------------------------------------------------------------------------------
// set Transmit PDO 2 to cyclic, every second SYNC message
//
// .. other code
}
CosPdoCom_ts atsTrmPdoComG[]
@ ePDO_TYPE_SYNC_2
Definition cos_pdo.h:163
@ ePDO_TYPE_SYNC_1
Definition cos_pdo.h:160
void CosPdoComSetup(void)
Setup application specific PDO communication parameter.
uint8_t ubTransType
Definition cos_pdo.h:224

Setting the Event Timer

In order to use the event timer, the transmission type of the PDO must have a value > 253 (i.e. ePDO_TYPE_EVENT_MANUFACTURER or ePDO_TYPE_EVENT_PROFILE).

All timer values are internally converted into timer ticks, hence a required time must be converted into tick value by means of CosTmrCalcTicks(). The following example shows how to configure Transmit PDO 1 with an event timer value of 100 ms.

void CosPdoComSetup(void)
{
// .. other code
//------------------------------------------------------------------------------------
// set Transmit PDO 1 to event
//
//------------------------------------------------------------------------------------
// configure both, tick value and reload value with 100 ms
//
// .. other code
}
@ ePDO_TYPE_EVENT_MANUFACTURER
Definition cos_pdo.h:187
uint16_t CosTmrCalcTicks(uint16_t uwReqTimingV)
uint16_t uwEventTick
Definition cos_pdo.h:254
uint16_t uwEventTime
Definition cos_pdo.h:248