µTasker Forum
µTasker Forum => NXPTM M522XX, KINETIS and i.MX RT => Topic started by: tr111 on November 22, 2007, 09:11:56 AM
-
static void fnConfigCAN_BUS(void)
{
CANTABLE tCANParameters; // table for passing information to driver
tCANParameters.Task_to_wake = OWN_TASK; // wake us on buffer events
tCANParameters.Channel = 0; // first hardware interface
tCANParameters.ulSpeed = 100000; // 100K speed
tCANParameters.ulTxID = 0x80; // default ID of destination
tCANParameters.ulRxID = (CAN_EXTENDED_ID | 0x00000105); // our ID
tCANParameters.ulRxIDMask = CAN_EXTENDED_MASK;
// use all bits for compare
tCANParameters.usMode = 0x01; // use lpb mode
tCANParameters.ucTxBuffers = 2; // assign two tx buffers for use
tCANParameters.ucRxBuffers = 3; // assign three rx buffers for use
CAN_interface_ID = fnOpen( TYPE_CAN, FOR_I_O, &tCANParameters );
}
static void fnSENDCAN_BUS(void)
{
unsigned char ucTestMessage[] = {1,2,3,4,5,6,7}; // Test message
if (fnWrite(CAN_interface_ID, ucTestMessage, sizeof(ucTestMessage))
!= sizeof(ucTestMessage)) {
// Error. Eg. no transmission buffer free
fnDebugMsg("\n\r SENT ERROR\n\r");
}
tCANParameters.usMode = 0x01; // use lpb mode
this is the CAN_LOOPBACK,and the fnWrite(CAN_interface_ID, ucTestMessage, sizeof(ucTestMessage)) is OK!
but I can't get anything from the CAN-BUS using the OSCILLOSCOPE!
what about the tCANParameters.Channel = 0; // first hardware interface
the 52235 have more CANTX and CANRX ,now we are use the PASPAR |= 0xa0; // configure AS port 2,3 as CAN
I don't sure the set #define NUMBER_CAN 3,now WE are use the #define NUMBER_CAN 2.
how can I get the data?????? I don't know!
-
Hi
I don't remember exactly how the loop mode is realised but it may be that it is an internal loop and so no data is actually sent out onto the bus. In this case it is possibly normal that no data can be measured with an oscilloscope, but the message may still be received.
The number NUMBER_CAN can be set to reserve resources for each 'logical' CAN interface which you need. The maximum amount of logical interfaces possible depends on the CAN controller in the processor. If you simply open one CAN interface a value of 1 is adequate. If you have two logical interfaces (eg. 2 tasks which can be viewed as independent TX/RX addresses on the CAN bus) it can be set to 2, etc. Although the M5223X has only one physical CAN interface it supports up to 8 logical interfaces, each with its own address on the CAN bus.
Regards
Mark
PS. When developing with the CAN bus it is useful to have a CAN module which can be used to analyse data on the bus and generate traffic - this also acts as a sink to the CAN interface. Alternatively 2 development boards can be used to ensure that the basic CAN HW protocol can operate correctly.