Sending float over serial communication
Hello,
I'm actually trying to send data from the software Serial Port Monitoring to my dev board SPC574S-DISP.
But it doesn't work.
When i send a number like "3", it works.
But when i try to send "3,3" or "12", the board takes only the first number "3" or "1" and not the others.
Can you help me ?
I give you my main part if it can help you :
/* define a vector containing the channels to be converted */
#define NUMOFCHANNELS 1U
extern uint8_t anp[NUMOFCHANNELS];
extern float value[NUMOFCHANNELS];
extern float tension;
float tension;
uint8_t anp[NUMOFCHANNELS] = {5U};
float value[NUMOFCHANNELS] = {0U};
/* conversion callback */
void saradcconf_conv_cb(SARADCDriver *saradcp) {
uint8_t i;
/* Read converted channels */
for (i = 0; i < NUMOFCHANNELS; i++) {
value[i] = (tension*saradc_lld_readchannel(saradcp, anp[i]))/4095;
}
}
/*
* Application entry point.
*/
int main(void) {
uint8_t i;
SARADCDriver* driverUnderTest;
/* change driverUnderTest value to test others SARADC modules. */
driverUnderTest = &SARADC12D2;
/* Initialization of all the imported components in the order specified in
the application wizard. The function is generated automatically.*/
componentsInit();
/* Enable Interrupts */
irqIsrEnable();
/* Start Serial Driver */
sd_lld_start(&SD2, NULL);
/* Start SARADC Driver */
saradc_lld_start(driverUnderTest, &saradc_config_saradcconf);
// Asking tension value
printf("\n Enter a numerator tension value \n");
scanf("%f", &tension);
printf("tension = %f \n", tension);
/* start SARADC conversion */
saradc_lld_start_conversion(driverUnderTest);
// Waiting Time
osalThreadDelayMilliseconds(1U);
/* Application main loop.*/
for (;;) {
/* print converted value on serial port each 100ms */
for (i = 0; i < NUMOFCHANNELS; i++) {
printf("CHANNEL %d: VALUE: %f V ", anp[i], value[i]);
}
printf("\n\r");
pal_lld_togglepad(PORT_E, PE_LED2);
osalThreadDelayMilliseconds(100U);
}
}Thank you,
Sincerely
Bastion

