Hello Mikroe,
I'm working with the mikromedia for STM32 (STM32F407VGT6).
I ask you like read an analog PIN and allocate the value to floating point variable.
I tried to execute it creating the follow code:
void Screen2_DA (){
float an;
char bant[15];
GPIO_Set_Pin_Mode(&GPIOA_BASE, _GPIO_PIN_1, _GPIO_CFG_MODE_ANALOG); // PA1 like an analog pin
an= GPIOA_BASE; // I try to allocate the analog value from PA1 to an (I think that there is my problem)
FloatToStr(an, bant);
TFT_Write_Char(bant[0], 100, 30);
TFT_Write_Char(bant[1], 110, 30);
TFT_Write_Char(bant[2], 120, 30);
TFT_Write_Char(bant[3], 130, 30);
}
After the bulded firmware there aren't syntax errors but after programming the display doesn't view the update from PA1.
Trank you so much
Read an analog PIN for Mikromedia STM32
-
- Posts: 4
- Joined: 02 Jan 2024 20:24
- IvanJeremic
- mikroElektronika team
- Posts: 316
- Joined: 05 Sep 2022 14:32
Re: Read an analog PIN for Mikromedia STM32
Hi,
Try using our ADC library and then try to display the data.
I have attached an example below: Also try debugging the code, see if it freezes somewhere or it just cant display the data.
Regards,
Ivan.
Try using our ADC library and then try to display the data.
I have attached an example below: Also try debugging the code, see if it freezes somewhere or it just cant display the data.
Regards,
Ivan.
-
- Posts: 4
- Joined: 02 Jan 2024 20:24
Re: Read an analog PIN for Mikromedia STM32
Hi Ivan,
I thank you so much for your answer but my problem is to read from an analog input voltage (PA6 for example) and not set a digital output. However your demo rar was important for to remember the ADC module. Next you can see my code to read from an analog voltage PIN without syntax error, but it doesn't view on the display the correct number.
void Screen2_DA (){
float a;
char b[100];
unsigned adc_value;
GPIO_Analog_Input(&GPIOA_BASE, _GPIO_PINMASK_6); // Set PORTA as input PA6
ADC_Set_Input_Channel(6); // Choose ADC channel
ADC1_Init();
adc_value= ADC1_Get_Sample(6);
Delay_ms(1000);
a=adc_value;
FloatToStr(a, b);
TFT_Write_Char(b[0], 100, 30);
TFT_Write_Char(b[1], 110, 30);
TFT_Write_Char(b[2], 120, 30);
}
What should be the best solution for you?
Thank you again
Antonio Dati
I thank you so much for your answer but my problem is to read from an analog input voltage (PA6 for example) and not set a digital output. However your demo rar was important for to remember the ADC module. Next you can see my code to read from an analog voltage PIN without syntax error, but it doesn't view on the display the correct number.
void Screen2_DA (){
float a;
char b[100];
unsigned adc_value;
GPIO_Analog_Input(&GPIOA_BASE, _GPIO_PINMASK_6); // Set PORTA as input PA6
ADC_Set_Input_Channel(6); // Choose ADC channel
ADC1_Init();
adc_value= ADC1_Get_Sample(6);
Delay_ms(1000);
a=adc_value;
FloatToStr(a, b);
TFT_Write_Char(b[0], 100, 30);
TFT_Write_Char(b[1], 110, 30);
TFT_Write_Char(b[2], 120, 30);
}
What should be the best solution for you?
Thank you again
Antonio Dati
- IvanJeremic
- mikroElektronika team
- Posts: 316
- Joined: 05 Sep 2022 14:32
Re: Read an analog PIN for Mikromedia STM32
Hi,
"but it doesn't view on the display the correct number", can you explain in more detail what exactly happens?
How is the data displayed not correct, can you send me a picture of your display?
Regards,
Ivan.
"but it doesn't view on the display the correct number", can you explain in more detail what exactly happens?
How is the data displayed not correct, can you send me a picture of your display?
Regards,
Ivan.
-
- Posts: 4
- Joined: 02 Jan 2024 20:24
Re: Read an analog PIN for Mikromedia STM32
Hello Ivan,
In the attachment you can find the picture.
I want only displays the voltage input from multimeter to the Mikromedia display.
I don't find any reference on the library help document (library GPIO)
Thank you so much for the patience.
Antonio Dati
In the attachment you can find the picture.
I want only displays the voltage input from multimeter to the Mikromedia display.
I don't find any reference on the library help document (library GPIO)
Thank you so much for the patience.
Antonio Dati
- Attachments
-
- Analog input
- IMG_20240116_214847.jpg (5.88 MiB) Viewed 502 times
- IvanJeremic
- mikroElektronika team
- Posts: 316
- Joined: 05 Sep 2022 14:32
Re: Read an analog PIN for Mikromedia STM32
Hi,
Sorry for the delay.
You need to convert the raw data into voltage.
You can use the forum below as a reference:
viewtopic.php?t=18427
Regards,
Ivan.
Sorry for the delay.
You need to convert the raw data into voltage.
You can use the forum below as a reference:
viewtopic.php?t=18427
Regards,
Ivan.
-
- Posts: 4
- Joined: 02 Jan 2024 20:24
Re: Read an analog PIN for Mikromedia STM32
Hi Ivan,
No problem for delay and thank you.
Antonio
No problem for delay and thank you.
Antonio