help needed in AT89C4051

OP #258787
Hi,
I am a new comer to the field of microcontrollers and doing some simple
projects to get familiar with microcontrollers. Currently i am embarking
on using the AT89C4051 as an ADC . I am actually trying to use the
application notes provided by the following website:
h**p://www.atmel.com/dyn/resources/prod_documents/DOC0524.PDF
It would be very useful if someone were to help me with the coding
(C-program) for the application. I have tried a few times but have
failed. Your help would be greaatly appreciated.
I have done the conections for the ADC conversion and had connected the
positive voltage of the signal to Pin 1.1. and i wrote a very simple
program, that would be able to output voltage reading on the LEDs,.
The program is of as follows:

#include<AT89x051.h>

char a[10]={0x03,0x13,0x23,0x33,0x43,0x53,0x63,0x73,0x83,0x93}; /* The
numbering from 0-9*/


void main(void)

{int j, adc_data;
while(1){

P1_1=adc_data;
P1=a[adc_data%10];
for(j=0;j<30000;j++);

}
}


I do always get a zero on my LED display, no matter how i changed the
voltage input, Could someone please help.I am struggling with this for
a few days. Thank you
Gast #258788
Vinash, are you sure you understood the schematic in the application
note ? I don't want to be the spoil sport but it looks like your lack
of C programming skills is not your only problem :

1. you have no I/O port setup at all
2. the schematic shows you'll have to toggle pin 1.2 and 1.3 to
generate the clock signals that make the displays latch the data setup
on pin 1.4 .. 1.7
3. your code assign a value to a pin/port rather than reading from it

I recommend to start trying to figure out how to do the initial setup
first (reading the uC datasheet might be helpfull).

  Daz
Gast #258789
Hello Vinash,

the Daz may be right, perhaps you should start with some µC basics,
like toggling I/O pins and switching simple LEDs before you start with
AD conversion.

Which development environment / C-Compiler do you use?

Markus_8051

Antwort schreiben

Eine eigene Frage? Dieser Thread ist über 20 Jahre alt. Stell sie in einem eigenen Thread – dort lesen mehr Leute mit, und sie wird öfter und schneller beantwortet.

Neuen Thread starten

Eine Lösung, Ergänzung oder Rückmeldung zu diesem Thread? Dann antworte hier.

Formatierung
  • [c]C-Code[/c]
  • [code]Code in anderen Sprachen, ASCII-Zeichnungen[/code]
  • [math]Formel in LaTeX-Syntax[/math]
  • [[Titel]] – Link zu einem Artikel
  • Verweis auf einen anderen Beitrag: Rechtsklick auf dessen Beitrags-ID (#8078628), „Adresse kopieren“, in den Text einfügen

Mehr zur Formatierung

Längeren Sourcecode als Anhang, nicht in den Text. JPG nur für Fotos und Scans; Zeichnungen und Screenshots als PNG oder GIF. Siehe Bildformate.

Schon registriert? Anmelden

Wird nicht angezeigt. Wir schicken dir einen Link; sobald du damit bestätigst, erscheint dein Beitrag.

Mit dem Abschicken legst du einen kostenlosen Account an und erkennst die Nutzungsbedingungen und die Datenschutzerklärung an.