5 years, 5 months ago.

disco-f746ng adc

Hi i try to read A0 but it is not working.

my code:

#include "mbed.h"
#include "LCD_DISCO_F746NG.h"

LCD_DISCO_F746NG lcd;

DigitalOut led1(LED1);

DigitalOut redled(D10);
DigitalOut irled(D11);

AnalogIn   ain(A0);

int xn;
int yn;
int xold;
int yold;
int deger;

int main()
{  
    led1 = 1;
    redled=1;
    irled=0;
    
    wait(1);
    lcd.Clear(LCD_COLOR_BLUE);
    lcd.SetBackColor(LCD_COLOR_BLUE);
    lcd.SetTextColor(LCD_COLOR_WHITE);
    lcd.DrawLine(20,200,400,200);
    lcd.SetTextColor(LCD_COLOR_YELLOW);
    lcd.DrawLine(20,100,400,100);   
    lcd.SetTextColor(LCD_COLOR_WHITE); 
    lcd.DrawLine(20,20,20,200);

    lcd.SetTextColor(LCD_COLOR_RED);
    
    xn=21;
    yn=100; 
    xold=21;
    yold=100;    
    while(1)
    {
      wait_ms(20);
      xn++;
      yn=(ain.read_u16()/450)+10;
      lcd.DrawLine(xold,yold,xn,yn);

      if(xn>=420)
      {
        xn=21;
        lcd.Clear(LCD_COLOR_BLUE);
        lcd.SetBackColor(LCD_COLOR_BLUE);
        lcd.SetTextColor(LCD_COLOR_WHITE);
        lcd.DrawLine(20,200,400,200);
        lcd.SetTextColor(LCD_COLOR_YELLOW);
        lcd.DrawLine(20,100,400,100);   
        lcd.SetTextColor(LCD_COLOR_WHITE); 
        lcd.DrawLine(20,20,20,200);
    
        lcd.SetTextColor(LCD_COLOR_RED);        
      }
      
      
      xold=xn;
      yold=yn;
            
    }
    
    

}

Question relating to:

The STM32F746G-DISCO discovery board (32F746GDISCOVERY) is a complete demonstration and development platform for STMicroelectronics ARM® Cortex®-M7 core-based STM32F746NGH6 microcontroller.

What is connected to A0? And what do you mean, does not work? What's the value that you get back from `ain.read_u16()` ?

posted by Jan Jongboom 30 Mar 2016

hi i connect 0 -3v analog signal to A0 pin. and i saw 0 value on adc via serial port. can you send me sample code. thanks.

posted by emin demir 30 Mar 2016

Hi i solved problem. ichanged mbed lib new one. and ok. thanks

posted by emin demir 30 Mar 2016
Be the first to answer this question.