2019-01-11 08:34 AM
void app_SendBuffer (void *argument) {
uint32_t dma_index;
char Message1[26];
bool a;
sprintf (Message1, "BufferSize_inBytes = %u\n", AdcHalfBufferSize_inByte);
osDelay(5000);
while (!USBD_Configured(0)) {
osThreadYield ();
}
USBD_CDC_ACM_WriteData(0U,(uint8_t*)Message1,sizeof(Message1));
ADC_DMA_Start();
for (;;){
osThreadFlagsWait(0x00000020U,osFlagsWaitAll,osWaitForever);
dma_index = osThreadFlagsWait(0x00000006U,osFlagsWaitAny,osWaitForever);
a=dma_index&2;
GPIO_PinWrite (GPIOC,14,a);
sprintf (Message1, "Index = %u", a);
USBD_CDC_ACM_WriteData(0U,(uint8_t*)Message1,9);
}
}
Here is my example code , i can get "a" value as 1,0,1,0,1,0 .Code works as i expected.
But if i try to write directly index as like this ;
I always read 2,2,2, then always 5
dma_index = (osThreadFlagsWait(0x00000006U,osFlagsWaitAny,osWaitForever) );
a=dma_index&2;
GPIO_PinWrite (GPIOC,14,a);
sprintf (Message1, "Index = %u", dma_index);
USBD_CDC_ACM_WriteData(0U,(uint8_t*)Message1,9);
dma_index did not used in anywhere of the project. So how can this be possible ?
How dma_index can be same value but "a" is alternating ?
Solved! Go to Solution.
2019-01-11 06:47 PM
Solved guys =)
it seems i was trying to print 52 or 54 but i just set buffer size 9 in USB function so i could see just "5" very left digit of two digit number such as 52 or 54 :))
Th solution is increasing buffersize in USBD_CDC_ACM_WriteData(0U,(uint8_t*)Message1,9); function .
USBD_CDC_ACM_WriteData(0U,(uint8_t*)Message1,15);
Best regards.
2019-01-11 09:16 AM
I have changed it like this but still no success ;
i also tried to take out dma_index variable to global or i put volatile ....
optimization level is 0
int32_t state = osKernelLock();
sprintf (Message1, "Index = %d", dma_index);
osKernelRestoreLock(state);
2019-01-11 06:47 PM
Solved guys =)
it seems i was trying to print 52 or 54 but i just set buffer size 9 in USB function so i could see just "5" very left digit of two digit number such as 52 or 54 :))
Th solution is increasing buffersize in USBD_CDC_ACM_WriteData(0U,(uint8_t*)Message1,9); function .
USBD_CDC_ACM_WriteData(0U,(uint8_t*)Message1,15);
Best regards.