Hi All,
I am quite new with DCAN commuication. At the moment I am using HalCoGen for helping me programming the Hercules microcontrollers.
Now I am stuck with making the comunication possible between the TMS570LS1227 development kit and the TMS570LS1224 Launchpad. (Communication with two of the CAN modules of the same card, TMS570LS1227 or TMS570LS1224, has allready being done and it works fine).
The TMS570LS1227 is being used as the transmitter and the TMS570LS1224 as the receiver. I take care in the HalCoGen adjustments to make the Bit Rate and Nominal Bit Time at each of the microcontrollers to be the same. The conection of the CAN modules is being made as in the following link (www.element14.com/.../probing-your-hercules-launchpad-can-bus). The TMS570LS1227 is sending the serial message (i can see it on the oscilloscope), but the TMS570LS1224 is not reading the message, actually is doing nothing and I really don’t know why (it's an easy example and i am confused).
Could it be some problems with the DCC, just because one of them has a clk of 90 [MHz] and the other has a 80[MHz]. (but as much as I understand bit rate and nominal bit time are the imprtant staff for receiving the message properly, that´s why there are prescalers, isn´t it?).
I will put my code and images of the HalCoGen configuration below.
Best regards and I wish my problem is understandable despite my lack of english writing
Franciso Dumont
Driver enable:
PinMux:
CAN2 general Settings:
CAN2 Message Config:
The lenght of data is just 1 byte in both of them.
DCC (1 & 2):
In the GIO and HET1 window there were some configurations, but just for adjust some outputs for LED´s and inputs por the user Switch on each board.
Code of the TMS570LS1224:
/* USER CODE BEGIN (0) */
#include "can.h"
#include "gio.h"
#include "het.h"
#include "system.h"
#include "esm.h"
#include "sys_core.h"
/* USER CODE END */
/* USER CODE BEGIN (1) */
#define D_SIZE 1
uint8 rx_data[D_SIZE]={0};
uint32 cnt=0;
/* USER CODE END */
/* USER CODE BEGIN (3) */
gioInit();
hetInit();
canInit();
while(1)
{
gioSetBit(gioPORTB, 2, 1); // this led is just to see if it some kind of change
while(!canIsRxMessageArrived(canREG2, canMESSAGE_BOX1)){};
canGetData(canREG1, canMESSAGE_BOX1, rx_data);
// see on external Leds the four bits that were send
gioSetBit(hetPORT1,14, (rx_data[0] & (1<<0)));
gioSetBit(hetPORT1,12, (rx_data[0] & (1<<1)));
gioSetBit(hetPORT1, 4, (rx_data[0] & (1<<2)));
gioSetBit(hetPORT1, 9, (rx_data[0] & (1<<3)));
gioSetBit(gioPORTB, 2, 0);
for(cnt=0; cnt<=0x00A0FFFF; cnt++){}; // some kind of delay to see the Led gioPORTB,2 blink
}
/* USER CODE END */
Code on TMS570LS1227:
/* USER CODE BEGIN (0) */
#include "can.h"
#include "gio.h"
#include "het.h"
#include "esm.h"
#include "system.h"
#include "sys_core.h"
/* USER CODE END */
/* USER CODE BEGIN (1) */
#define D_SIZE 1
uint8 tx_data[D_SIZE]={0x05};
uint32 cnt=0;
/* USER CODE END */
/* USER CODE BEGIN (3) */
canInit();
gioInit();
hetInit();
while(1)
{
// some led to see if there is something going on
gioSetBit(hetPORT1, 29, 0);
if(gioGetBit(gioPORTA, 7)==0)
{
gioSetBit(hetPORT1, 29, 1);
canTransmit(canREG2, canMESSAGE_BOX1, tx_data);
// external leds to see what was the message send like
gioSetBit(gioPORTB, 4, (tx_data[0] & 1<<0));
gioSetBit(gioPORTB, 5, (tx_data[0] & 1<<1));
gioSetBit(gioPORTB, 6, (tx_data[0] & 1<<2));
gioSetBit(gioPORTB, 7, (tx_data[0] & 1<<3));
// kind of delay to see the led on hetPORT1, 29 blink and so that the switch doesn´t enter in the if so often
for(cnt=0; cnt<0x00A0FFFF; cnt++){};
}
}
/* USER CODE END */