It is currently 25 Feb 2018 00:52

All times are UTC + 1 hour




Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: CAN Mikromedia 7
PostPosted: 03 Jan 2018 16:26 
Offline

Joined: 03 Jan 2018 16:22
Posts: 1
Hello guys,

I am having some issues with some code I am not sure why the CAN read will not work however the write function does. This is for the mikromedia 7 for stm32f7. I can see that the data is actually sending however I cannot read data.


void startCAN(){
Can_Init_Flags = 0; //
Can_Send_Flags = 0; // clear flags
Can_Rcv_Flags = 0; //

Can_Send_Flags = _CAN_TX_XTD_FRAME & // with CANWrite
_CAN_TX_NO_RTR_FRAME;

Can_Init_Flags = _CAN_CONFIG_AUTOMATIC_RETRANSMISSION & // form value to be used
_CAN_CONFIG_RX_FIFO_NOT_LOCKED_ON_OVERRUN & // with CANInit
_CAN_CONFIG_TIME_TRIGGERED_MODE_DISABLED &
_CAN_CONFIG_TX_FIFO_PRIORITY_BY_IDINTIFIER &
_CAN_CONFIG_WAKE_UP;
CAN1InitializeAdvanced(SJW, BRP, PHSEG1, PHSEG2, PROPSEG, CAN_CONFIG_FLAGS, &_GPIO_MODULE_CAN1_PD01);

CAN1SetOperationMode(_CAN_OperatingMode_Initialization); // set CONFIGURATION mode

// CANSetFilterScale32(0, _CAN_FILTER_ENABLED & _CAN_FILTER_ID_MASK_MODE & _CAN_FILTER_STD_MSG, -1, 0);
CANSetFilterScale32(0, _CAN_FILTER_ENABLED & _CAN_FILTER_ID_MASK_MODE & _CAN_FILTER_XTD_MSG, ID_1st, -1);


CAN1SetOperationMode(_CAN_OperatingMode_Normal); // set NORMAL mode
}


void doCAN() {
char i, flag;

Can_Init_Flags = 0; //
Can_Send_Flags = 0; // clear flags
Can_Rcv_Flags = 0; //

Can_Send_Flags = _CAN_TX_XTD_FRAME & // with CANWrite
_CAN_TX_NO_RTR_FRAME;

Can_Init_Flags = _CAN_CONFIG_AUTOMATIC_RETRANSMISSION & // form value to be used
_CAN_CONFIG_RX_FIFO_NOT_LOCKED_ON_OVERRUN & // with CANInit
_CAN_CONFIG_TIME_TRIGGERED_MODE_DISABLED &
_CAN_CONFIG_TX_FIFO_PRIORITY_BY_IDINTIFIER &
_CAN_CONFIG_WAKE_UP;


Msg_Rcvd = CAN1Read(0, &Rx_ID , RxTx_Data , &Rx_Data_Len, &Can_Rcv_Flags); // receive message
if(Msg_Rcvd != 0){
TFT_Set_Font(TFT_defaultFont, CL_WHITE, FO_HORIZONTAL);
TFT_Write_Text((int*) "right", 520, 440);
CAN1Write(90, &RxTx, 8, Can_Send_Flags);
}
if(Msg_Rcvd == 0){
TFT_Set_Font(TFT_defaultFont, CL_WHITE, FO_HORIZONTAL);
TFT_Write_Text((int*) "not working", 520, 440);
}

CAN1Write(90, &RxTx, 8, Can_Send_Flags);
}


Top
 Profile  
 
 Post subject: Re: CAN Mikromedia 7
PostPosted: 11 Jan 2018 16:48 
Offline
mikroElektronika team
User avatar

Joined: 02 Feb 2017 14:21
Posts: 780
Hi,

CANSetFilterScale32(0, _CAN_FILTER_ENABLED & _CAN_FILTER_ID_MASK_MODE & _CAN_FILTER_XTD_MSG, ID_1st, -1);

The ID(ID_1st) of the mikromedia is set in the function mentioned above.

The device will receive a message if the ID is matching the one set inside of that function.
Do you have the correct id set on the second CAN device ?

Best Regards,

_________________
Dusan Poluga.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to: