Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Using ADC n PWM to light up the LED dimmer - need help

Status
Not open for further replies.
Re: i am doing ADC

thank for the replying mi, if he will explain to mi den i post here for what?
 

i am doing ADC

The comments in the code tell what the code is doing.

Your teacher gave this to you to debug so you could learn to program.

Do you not know how to program in C ?
 

Re: i am doing ADC

i dunno hw to program in C.. and i have a hex file.. how to download to the board using silicon software? what kind of result if i download the code to ther board? and kinda tell mi the code what he is doin?

#include<c8051f200.h>




//definitions
sbit LED = P2^4;


void adc_init(); //to initialize adc
void port_init(); //to initialize the ports

void main()
{

unsigned int index=0, total_period= (unsigned int) 255*256, on_time=0;
port_init();
adc_init();


// disable watchdog timer
WDTCN = 0xde;
WDTCN = 0xad;


{
ADBUSY = 0x01; //starts the adc conversion
while(ADCINT); //polling for ADCINT which tells us the end of conversion
ADCINT = 0x00;
on_time = ((unsigned int)ADC0H)*256;
for ( index = 0 ; index < total_period ; index++)
{
if (on_time--)
{
LED = 0x01; //switching on the LED

}

else
{
LED = 0x00; //switching off the LED
}
}
}
}

void adc_init ()

{
AMX0SL = 0x3f; // enable AMUX & configure for p3.7 as i/p pin
ADC0CF = 0x60; // set conversion clk at one sys clk and PGA at gain =1
ADC0CN = 0xC0; // ADC is enabled and ADBUSY=0 (changed here)
REF0CN = 0x03; // VDD is selected as Vref. Here are you using VDD for variable resistor also?
}
void port_init()
{
P3MODE = 0X7F; // Except the P3.7 pin all are configured as digital I/O
}
 

i am doing ADC

You have to compile the code first. Makes no sense your teacher would expect you to be able to understand the code if you can't program in C

I recommend a getting a book on C

PS what does "mi" mean?
 

Re: i am doing ADC

but do u noe what the code is doing anot? if i have the book i wont be posting here
 

Re: i am doing ADC

jason1987 said:
but do u noe what the code is doing anot? if i have the book i wont be posting here


Sorry I don't understand your question?

As for the book why do you want to post it? I don't need a C book I have a couple.
 

Re: i am doing ADC

i don't undestand the code that why i post here for help.. i don't have the book tat why if u know try to help mi.. thank
 

i am doing ADC

Try Google for C tutorials. The code is pretty straight forward. Don't bother with C# tutorials just look for ANSI C
 

Re: i am doing ADC

jason1987 said:
u r giving mi rubbish ans

No. I'm telling you to read a book on the subject.

Waiting for other folks to do your homework for you is fools game. Unless you start taking your homework seriously you have a decent chance of failing that course.
 

Re: i am doing ADC

i also noe. but i dun understand the code is writing
 

Re: i am doing ADC

u noe wat my code doing anot?

Added after 11 minutes:

u very lousy in programming.. jus sae u noe anot
 

Re: i am doing ADC

I'm pretty good at programming. And yes I do understand the code you posted earlier. But it's not my school assignment it's yours so it's you that needs to learn to understand it.

Added after 9 minutes:

jason1987 said:
u noe wat my code doing anot?

Added after 11 minutes:

u very lousy in programming.. jus sae u noe anot

Translator says.

Do you know what my teachers code is doing?

I am very lousy in programming.. I will probably have to repeat a grade.
 

Re: i am doing ADC

den jus tell mi what does the code do first. .cos is urgent
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top