2023-05-18 04:01 PM
I have rfid and can working. I want to do is increase the cycle time for can so it is not too fast. Right now i am getting 0.3 cycle time and when i add the HAL_Delay(200) it increases the cycle time but the rfid slows down. Any suggestions what i can do?
What i want to do is send the rfid reading over the CAN when nfcv is detected if not detected then send zero's only.. When i add HAL_Delay(200) the entire system gets the delay i only want to add that to can transmission. Please guide me. I am very new to stm32
Solved! Go to Solution.
2023-05-22 08:34 AM
this is the solution for this. Topic resolved
if(&nfcDevice->dev.nfcv)
{
platformLedOn(PLATFORM_LED_V_PORT, PLATFORM_LED_V_PIN);
while (rfalNfcvPollerInventory( RFAL_NFCV_NUM_SLOTS_1, RFAL_NFCV_UID_LEN * 8U, nfcDevice->dev.nfcv.InvRes.UID, &invRes, &rcvdLen) == ERR_NONE)
{
platformDelay(500);
HAL_CAN_AddTxMessage(&hcan1, &TxHeader, nfcDevice->nfcid, &TxMailbox);
}
}
2023-05-22 05:53 AM
Hi,
you can try something like:
tickStart = HAL_GetTick();
if( (HAL_GetTick() - tickStart) > yourDesiredCanCyclePeriod-i.e._200)
{
yourCanCycle()
tickStart = HAL_GetTick();
}
Rgds
BT
2023-05-22 08:18 AM
I tried it but it didn't work. I want to constantly send zeros through can but when nfcv is detected then send the uid over can. here is what i did. the first part is in democycle function and the last part is in the main function.
if(&nfcDevice->dev.nfcv)
{
HAL_CAN_AddTxMessage(&hcan1, &TxHeader, nfcDevice->nfcid, &TxMailbox);
}
CAN_TxHeaderTypeDef TxHeader;
CAN_RxHeaderTypeDef RxHeader;
uint8_t TxData[8] = {0,0,0,0,0,0,0,0};
uint32_t TxMailbox;
if((HAL_GetTick()- tickstart) > 200)
{
HAL_CAN_AddTxMessage(&hcan1, &TxHeader, TxData, &TxMailbox);
tickstart = HAL_GetTick();
}
2023-05-22 08:34 AM
this is the solution for this. Topic resolved
if(&nfcDevice->dev.nfcv)
{
platformLedOn(PLATFORM_LED_V_PORT, PLATFORM_LED_V_PIN);
while (rfalNfcvPollerInventory( RFAL_NFCV_NUM_SLOTS_1, RFAL_NFCV_UID_LEN * 8U, nfcDevice->dev.nfcv.InvRes.UID, &invRes, &rcvdLen) == ERR_NONE)
{
platformDelay(500);
HAL_CAN_AddTxMessage(&hcan1, &TxHeader, nfcDevice->nfcid, &TxMailbox);
}
}