Hi,
I am having some issues with trying to send information from an STM32F103C8T6 minimal development board using the USB in CDC mode.
I have used STMCubeMX to generate the startup code, and I am able to get the ADC working, and the USB working to a degree. I am able to send hard coded "test" out of the board to a PC terminal.
I am trying to read the ADC value, and then transfer this to the PC terminal but I am getting only rubbish ascii characters.
I consider myself a beginner in terms of microcontrollers and C programming.
The code I am using is below.
I am trying to read the ADC, turn this into a char * (I think) which can be transmitted to the PC using the CDC_Transmit_FS() function (which is a standard library function).
It complains that I can't return the array from the conversion function at the bottom (I thought that the problem with the program was that the USB transmission was being sent in the wrong format, and I'm trying to convert it to something more readable).
Any help please, or something that I can read?
Thanks
//unsigned char chunk []= {0x46,0x6F,0x6F,0x64,0x20,0x0D,0x0A};
unsigned char chunk [0xFF];
uint8_t sender[sizeof(chunk)];
HAL_Delay(1000);
uint16_t tres;
while (1)
{
/* USER CODE END WHILE */
/* USER CODE BEGIN 3 */
tres = Getval();
chunk[0] = tres;
for (int i=0; i < sizeof(chunk); i++){
sender[i] = chunk[i];
uint16_t p;
p = sizeof(sender[i]);
CDC_Transmit_FS(&sender[i],4);
HAL_Delay(100);
}
HAL_Delay(1000);
int bin2char(int binter){
int charback[4];
//int dib = binter/4;
int i = 4;
for (int j = 0; j == i; j++){
charback[j] = binter & 0x0F;
binter = binter >> 0x0F;
}
return charback;
}