Skip to main content
NAkku.1
Associate II
May 18, 2023
Solved

increase cycle time

  • May 18, 2023
  • 1 reply
  • 1225 views

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

This topic has been closed for replies.
Best answer by NAkku.1

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);
 	}
 }

1 reply

Brian TIDAL
Technical Moderator
May 22, 2023

Hi,

you can try something like:

tickStart = HAL_GetTick();

if( (HAL_GetTick() - tickStart) > yourDesiredCanCyclePeriod-i.e._200)

{

yourCanCycle()

tickStart = HAL_GetTick();

}

Rgds

BT

In order to give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
NAkku.1
NAkku.1Author
Associate II
May 22, 2023

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();
		}

NAkku.1
NAkku.1AuthorBest answer
Associate II
May 22, 2023

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);
 	}
 }