Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Event lost when sending through the USB to receiver.

Status
Not open for further replies.

asif45

New Member
Hi

I am using stm32f103RBT6 Microcontroller For sending timestamp in millisecond through usb to a receiver . The program works fine when when i am testing before sending through usb but after dending through usb in receiver sofware its missing a event (sometime it does lose event and sometimes not). Can anyone please tell me where the problem can be ? It's a big program so i can' upload the whole program. Will really appreciate any help. Thanks

Here is the Fifo stack part

Code (text):
Code (C):

typedef struct FifoStack
{
u16 u16EventTimeStampMSPart; //This variable have only the ms part!!!
u32 u32EventTimeStamp; // This variable have only the s part!!!
u8 u8EventInput;
} SFIFO_STACK;

// Private function prototypes -------------------------------------------------
void UsbConnect(void);
void StackPush(u32 u32EventTime, u16 u16EventTimeMS, u8 u8Input);
u8 StackPop(SFIFO_STACK *psFifoStack);
void GetMessage(u8 *pu8Buffer);
void TaskFilter(void);

// *****************************************************************************
/// @brief Function that saves an event in cell
/// @fn void StackPush(u32 u32EventTime, u16 u16EventTimeMS, u8 u8Input)
/// @param[in] u32EventTime @brief Hora do evento
/// @param[in] u16EventTimeMS @brief Hora do evento, ms part ASIF
/// @param[in] u8Input @brief Número da entrada que gerou o evento
// *****************************************************************************
void StackPush(u32 u32EventTime, u16 u16EventTimeMS, u8 u8Input)
{
if ((s16StackWriteIndex + 1) != s16StackReadIndex) // verifica se há espaço na pilha
{
sFifo[s16StackWriteIndex].u16EventTimeStampMSPart = u16EventTimeMS; //ASIF salva o time stamp na pilha, part MS

sFifo[s16StackWriteIndex].u32EventTimeStamp = u32EventTime; // salva o time stamp na pilha
sFifo[s16StackWriteIndex].u8EventInput = u8Input; // salva a entrada digital na pilha
s16StackWriteIndex++; // incrementa o índice de escrita
if (s16StackWriteIndex >= STACK_SIZE) // torna o índice de escrita circular
s16StackWriteIndex = 0;
}
}

// *****************************************************************************
/// @brief Function that retrieves a cell event
/// @fn u8 StackPop(SFIFO_STACK *psFifoStack)
/// @param[out] psFifoStack @brief Evento
/// @retval TRUE, se ok
// *****************************************************************************
u8 StackPop(SFIFO_STACK *psFifoStack)
{
if (s16StackReadIndex != s16StackWriteIndex) // verifica se há dados na pilha
{
psFifoStack->u16EventTimeStampMSPart = sFifo[s16StackReadIndex].u16EventTimeStampMSPart; //ASIF busca o time stamp da pilha, part MS

psFifoStack->u32EventTimeStamp = sFifo[s16StackReadIndex].u32EventTimeStamp; // busca o time stamp da pilha
psFifoStack->u8EventInput = sFifo[s16StackReadIndex].u8EventInput; // busca o número da entrada digital da pilha
s16StackReadIndex++; // incrementa o índice de leitura
if (s16StackReadIndex >= STACK_SIZE) // torna o índice de leitura ser circular
s16StackReadIndex = 0;
return TRUE;
}
else
return FALSE;
}
 

Attachments

  • missing event.png
    missing event.png
    363.6 KB · Views: 243
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top