below my replay at your consideration
1)
a) I Confirm that on the micro MK60DN512ZVLL10 we have cloned the BSP of TWR-K60N512, while for micro MK60FN1M0VLQ12 we have cloned the BSP of TWR-K60F120M.
b) For the new micro MK60FN1M0VLQ12 we have already changed the BSP considering that core clock is 120MHz.
2) We have always used the BSP cloned from TWR-K60120M.
3) I add that our application using 3 UART, 1 I2C, Ethernet, USB and uSD but we have problem only on CAN communication when the micro MK60FN1M0VLQ12 is used.
On the last days we have make the simple task below where a message is sent from port CAN1 and then a response is sent from port CAN0, and so on.
When transmission on CAN1 is completed then the call-back function "CANBUS1_OnFreeTxBuffer()" should be called from the interrupt and so the program can start to manage the Rx message.
The problem is that when on CAN1 is sent the massage with "CANBUS1_SendFrame(CANBUS1Ptr, 9, &Frame)" the call-back function "CANBUS1_OnFreeTxBuffer()" is correctly executed for the first 5-10 times (the number of times is random) and then the program remain on the loop "while ( (!DataFrameTxFlg[CAN_DEV1]) && (i<1000) ) {}" because the flag DataFrameTxFlg[CAN_DEV1] not became never "TRUE". The only way to exit from this loop is to disable and re-enable the CAN1 module and so the communication working correctly for 5-10times and so on.
At present we don't have "TWR-K60120M" and so we don't see if the problem is reproducible on this board also.
At your disposal for other information.
=============================================
void _CAN0Master_task(uint32_t initial_data)
{
short RetVal = 0;
unsigned char Data[8];
LDD_CAN_TFrame Frame;
LDD_TError ret;
unsigned short i=0;
/* Initialize the CANBUS1 device */
if( (CANBUS1Ptr = CANBUS1_Init((LDD_TUserData *)NULL)) != NULL )
{
// ricezione su Message Buffer 0 con ID=0x001, trasmissione su Message Buffer 9
if( CANBUS1_SetRxBufferID( CANBUS1Ptr, 0, 0x001 ) == ERR_OK ) /* Set new value of the Rx ID for receive buffer */
{
/* Initialize the CANBUS0 device */
if( (CANBUS0Ptr = CANBUS0_Init((LDD_TUserData *)NULL)) != NULL )
{
// ricezione su Message Buffer 0 con ID=0x002, trasmissione su Message Buffer 9
if( CANBUS0_SetRxBufferID( CANBUS0Ptr, 0, 0x002 ) == ERR_OK ) /* Set new value of the Rx ID for receive buffer */
{
// enable both CAN devices
CANBUS0_Disable( CANBUS0Ptr );
CANBUS1_Disable( CANBUS1Ptr );
_time_delay( 2 );
CANBUS0_Enable( CANBUS0Ptr );
CANBUS1_Enable( CANBUS1Ptr );
_time_delay( 2 );
// pausa iniziale
_time_delay(300);
// task loop
for(;;)
{
// Test CANBUS1 -> CANBUS0
memcpy( Data, VersSw, 8 );
Frame.MessageID = 0x002; /* Set Tx ID value - standard */
Frame.FrameType = LDD_CAN_DATA_FRAME; /* Specyfying type of Tx frame - Data frame */
Frame.Length = 8; /* Set number of bytes in data frame - 4B */
Frame.Data = Data; /* Set pointer to Data buffer */
var_debug1++;
DataFrameTxFlg[CAN_DEV1] = FALSE;
ret = CANBUS1_SendFrame(CANBUS1Ptr, 9, &Frame);
if( ret == ERR_OK ) /* Sends the data frame over buffer 1 */
//if( CANBUS1_SendFrame(CANBUS1Ptr, 9, &Frame) == ERR_OK ) /* Sends the data frame over buffer 1 */
{
var_debug2++;
// Wait Tx date frame trasmission is complete
i=0;
while ( (!DataFrameTxFlg[CAN_DEV1]) && (i<1000) )
{
i++;
if (i==1000)
{
// Resetto CAN1
CANBUS1_Disable( CANBUS1Ptr );
_time_delay( 2 );
CANBUS1_Enable( CANBUS1Ptr );
}
_time_delay( 1 );
TWDOG_CAN0_MASTER = 1;
}
// Rx date frame reading
while (!DataFrameRxFlg[CAN_DEV0])
{
_time_delay( 1 );
TWDOG_CAN0_MASTER = 1;
}
memset( Data, 0, 8 );
memset( &Frame, 0, sizeof(Frame) );
Frame.Data = Data; /* Set pointer to Data buffer */
if( CANBUS0_ReadFrame(CANBUS0Ptr, 0, &Frame) == ERR_OK ) /* Reads a data frame from buffer 0 and fills Frame structure */
{
var_debug3++;
/*
Frame.MessageID => Contains ID value. if((Frame.MessageID & LDD_CAN_MESSAGE_ID_EXT)!=0) then extended ID, else standard ID
Frame.FrameType => Type of Rx frame, e.g. LDD_CAN_DATA_FRAME
Frame.Length => Number of Rx bytes in Rx frame
Frame.Data => Contains Rx data bytes
*/
if( !(Frame.MessageID & LDD_CAN_MESSAGE_ID_EXT) &&
(Frame.MessageID == 0x002) &&
(Frame.Length == 8) &&
!memcmp( Frame.Data, VersSw, 8) )
{
// Test CANBUS1 -> CANBUS0 OK
var_debug4++;
}
}
DataFrameRxFlg[CAN_DEV0] = FALSE;
}
var_debug5 = ret;
_time_delay( 2 );
//The task was unblocked after the timeout.
TWDOG_CAN0_MASTER = 1;
}
}
}
}
}
}
/*
** ===================================================================
** Event : CANBUS1_OnFreeTxBuffer (module Events)
**
** Component : CANBUS1 [CANBUS1_LDD]
*/
/*!
** @brief
** This event is called when the buffer is empty after a
** successful transmit of a message. This event is available
** only if method SendFrame is enabled.
** @param
** UserDataPtr - Pointer to the user or
** RTOS specific data. This pointer is passed
** as the parameter of Init method.
** @param
** BufferIdx - Receive message buffer index.
*/
/* ===================================================================*/
void CANBUS1_OnFreeTxBuffer(LDD_TUserData *UserDataPtr, LDD_CAN_TMBIndex BufferIdx)
{
unsigned char entry;
CANBUF *pt;
if( BufferIdx >= MAX_NUM_DOUBLE_BUFFER )
{
entry = BufferIdx - MAX_NUM_DOUBLE_BUFFER;
pt = &CANBuf_tab[CAN_DEV1][entry];
if( pt->onCANtx != NULL )
pt->onCANtx();
}
DataFrameTxFlg[CAN_DEV1] = TRUE; /* Set DataFrameTxFlg flag */ // DA ELIMINARE: PER DEBUG CAN
}
====================================================================