cancel
Showing results for 
Search instead for 
Did you mean: 

how to properly cast ushort to float in Cortex M4 MCU

hashtala
Associate II

Hello

I have DMA ADC and store data in uint16_t buffer

I need to copy these values to input buffer to arm_rfft_fast_f32 function;

the function should also cast ushort to float

void copy_adc_to_input(uint16_t * int_buff, float32_t * float_buff, uint16_t size)

{

for(int i = 0; i < size; i++)

{

  float_buff[i] = (float32_t)int_buff[i];

}

}

it seems to be working on STM32F7 mcu but goes crazy on STM32F303

any suggestions ???

2 REPLIES 2
TDK
Guru

I don't see anything wrong with the code. What does "goes crazy" mean?

If you feel a post has answered your question, please click "Accept as Solution".

turns out this fft function modifies input buffer as well. That was the reason why I could not recognize what I was seeing.

At this stage I am witnessing rather strange thing. my adc is 12 bits resolution but values are in 16 bit for some reason.

I use uint16_t for buffer. I think I just need to shift down these values