Forum: Mikrocontroller und Digitale Elektronik help needed in AT89C4051


von Vinash K. (vinash)


Lesenswert?

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

von The Daz (Gast)


Lesenswert?

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

von Markus_8051 (Gast)


Lesenswert?

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

Bitte melde dich an um einen Beitrag zu schreiben. Anmeldung ist kostenlos und dauert nur eine Minute.
Bestehender Account
Schon ein Account bei Google/GoogleMail? Keine Anmeldung erforderlich!
Mit Google-Account einloggen
Noch kein Account? Hier anmelden.