free 8051 Microcontroller Projects AVR PIC Microcontroller Projects Tutorials Ebooks Libraries, interfacing tutorials, lcd tutorial, stepper motor, dc motor 8051 assembly language programming electronics and communication ECE CSE pdf ebooks library BE final year project ideas Embedded systems

 
8051 microcontroller 8051 microcontroller
Forums

Go to page  [1] 2
Moderators: Ajay, Junied , abbas1707, Arun Kumar V, pdi33, Shailesh NAYAK, ۞ TPS ۞, shyam, sashijoseph
Author Post
say2paul
Thu Jun 19 2008, 05:01AM
 User Offline
Registered Member #8461
Joined: Tue Jun 17 2008, 10:56AM

Posts: 123
Thanked 6 times in 6 posts
4 years back I did a project Home Automations using AT89C51, I need to do something similar to it. But I am facing a very strange problem this time.

I am reffering Embedded C book by Michael Pont, I used a very basic program (provided with the book) as under and compiled it using Keil compiler.

CODE:

/*------------------------------------------------------------*-
Hello.C (v1.00)
-------------------------------------------------------------
A "Hello Embedded World" test program for 8051.
-*------------------------------------------------------------*/


#include <reg52.h>

// LED is to be connected to this pin
sbit LED_pin = P1^5;

// Stores the LED state
bit LED_state_G;

// Function prototypes
void LED_FLASH_Init(void);
void LED_FLASH_Change_State(void);
void DELAY_LOOP_Wait(const unsigned int);

/*............................................................*/

void main(void)
{
        LED_FLASH_Init();
        while(1)
        {
        // Change the LED state (OFF to ON, or vice versa)
        LED_FLASH_Change_State();
        // Delay for *approx* 1000 ms
        DELAY_LOOP_Wait(1000);
        }
}

/*------------------------------------------------------------*-
LED_FLASH_Init()
Prepare for LED_Change_State() function – see below.
-*------------------------------------------------------------*/


void LED_FLASH_Init(void)
{
        LED_state_G = 0;
}

/*------------------------------------------------------------*-
LED_FLASH_Change_State()
Changes the state of an LED (or pulses a buzzer, etc) on a
specified port pin.
Must call at twice the required flash rate: thus, for 1 Hz
flash (on for 0.5 seconds, off for 0.5 seconds),
this function must be called twice a second.
-*------------------------------------------------------------*/


void LED_FLASH_Change_State(void)
{
        // Change the LED from OFF to ON (or vice versa)
        if (LED_state_G == 1)
        {
                LED_state_G = 0;
                LED_pin = 0;
        }
        else
        {
                LED_state_G = 1;
                LED_pin = 1;
        }
}

/*------------------------------------------------------------*-
DELAY_LOOP_Wait()
Delay duration varies with parameter.
Parameter is, *ROUGHLY*, the delay, in milliseconds,
on 12MHz 8051 (12 osc cycles).
You need to adjust the timing for your application!
-*------------------------------------------------------------*/


void DELAY_LOOP_Wait(const unsigned int DELAY)
{
        unsigned int x, y;
        for (x = 0; x <= DELAY; x++)
        {
                for (y = 0; y <= 120; y++);
        }
}

/*------------------------------------------------------------*-
---- END OF FILE --------------------------------------------
-*------------------------------------------------------------*/

 



The code compiled successfully without any errors and without any warning. Then I used BIN2HEX by Keil to convert the object (compiled) file to the HEX code.

Then I added the HEX file to the microcontroller in ISIS. Find below the image of the design.






I checked the code in the Keil simulator and it is working. I don't know why it is NOT working in ISIS. Please help me. Let me know where I am going wrong!

















[ Edited Thu Jun 19 2008, 05:07AM ]
Back to top


Colin Mac
Thu Jun 19 2008, 08:05AM
 User Offline
Registered Member #4338
Joined: Wed Oct 10 2007, 05:46AM

Posts: 56
Thanked 0 times in 0 posts
The crystal and supply isn't necessary in Isis and neither is the reset pin. Remove everything. Get a dc supply, resistor and use a red led instead of that led so only
P1.5 is being used.
Back to top


say2paul
Thu Jun 19 2008, 10:58AM
 User Offline
Registered Member #8461
Joined: Tue Jun 17 2008, 10:56AM

Posts: 123
Thanked 6 times in 6 posts
Colin Mac wrote ...

The crystal and supply isn't necessary in Isis and neither is the reset pin. Remove everything. Get a dc supply, resistor and use a red led instead of that led so only
P1.5 is being used.


Dear Colin,

I did as you said and the result is same. Please see the below image.



Back to top


Arun Kumar V
Thu Jun 19 2008, 08:52PM

 User Offline
Registered Member #426
Joined: Sun Jan 28 2007, 11:50PM

Posts: 427
Thanked 178 times in 149 posts
Hello say2paul

in the above layout you have 3 errors:
1) LED should be connected other way round i,e cathode to pin p1.5, bcoz micros like 8051 can sink current better than source

2) change resistor value to 100ohms

3) connect the other end of resistor to 5+ VCC not -5V


even if it doesn't work, then check the following :

1) double click on the red LED and its properties box will pop up, there find minimum trigger current field and change it to 2mA , by default it will be 10mA

2) since you are using external complier to produce hex file, are you loading it correctly into micro, double click the micro component and a see its properties box, there you'll find path of the hex file to loaded on the micro, browse for the correct hex file and update.

3) check if the port pin you have declared in the code is the same you have used in the schematic, save your design file and run the simulator, if every thing is right it should work.


all the best

Arun
Back to top


pdi33
Thu Jun 19 2008, 09:48PM

 User Offline
Registered Member #1329
Joined: Mon Jun 04 2007, 09:28AM

Posts: 628
Thanked 136 times in 132 posts
hi paul,
do as arun says and if u still do not get it, attach the DSN file and let me simulate the same on my PC and find the error for u.
Hope it works at ur place.
Good luck

* inspired to develop,developing to inspire *
Back to top


say2paul
Thu Jun 19 2008, 09:51PM
 User Offline
Registered Member #8461
Joined: Tue Jun 17 2008, 10:56AM

Posts: 123
Thanked 6 times in 6 posts
Dear pdi33,

I am trying as Arun said, but still unable to get the desired results.

Can you please do it for me, find attached the required DSN files.

http://www.8051projects.net/e107_files/public/1213937567_8461_FT10135_8051.zip

[ Edited Thu Jun 19 2008, 09:54PM ]
Back to top


say2paul
Thu Jun 19 2008, 09:52PM
 User Offline
Registered Member #8461
Joined: Tue Jun 17 2008, 10:56AM

Posts: 123
Thanked 6 times in 6 posts
say2paul wrote ...

Dear pdi33,

I am trying as Arun said, but still unable to get the desired results.

Can you please do it for me, find attached the required DSN files.


8051.zip
Back to top


Arun Kumar V
Fri Jun 20 2008, 06:30AM

 User Offline
Registered Member #426
Joined: Sun Jan 28 2007, 11:50PM

Posts: 427
Thanked 178 times in 149 posts
hello Say2paul

in your zip file there is no hex file that is to be loaded into the micro, but any way i made a simple blink program and could run it on the your Design, and here is the error you made






DIRECT SHORT to the port pin , try dragging the resistor in your DSN file and you'll see the blunder.








Now its Working !

there's a thanks button you could use


Arun
Back to top



This post has been thanked 1 time
 say2paul 
pdi33
Fri Jun 20 2008, 08:13AM

 User Offline
Registered Member #1329
Joined: Mon Jun 04 2007, 09:28AM

Posts: 628
Thanked 136 times in 132 posts
hi paul,
Arun is right. just connect the LED correctly and ur code will work just fine . I have compiled ur code posted previously and tested it in ur ciruit after correcting the LED connections and it worked just as fine.


* inspired to develop,developing to inspire *
Back to top


Ajay
Fri Jun 20 2008, 08:38AM
Rickey's World Admin

 User Offline

Registered Member #1
Joined: Fri Feb 24 2006, 04:56AM

Posts: 3686
Thanked 685 times in 647 posts
I hope you have loaded the code in controller before running on proteus

www.rickeyworld.info
If you feel satisfied with the user's forum reply please click on the thank button.

Obey forum rules!
Respect others!
Back to top


Go to page  [1] 2  

Jump:     Back to top

Syndicate this thread: rss 0.92 Syndicate this thread: rss 2.0 Syndicate this thread: RDF
Powered by e107 Forum System

8051 Microcontroller Projects 8051 AVR tutorials PIC microcontroller, 8051 assembly language programming electronics and communication ECE CSE pdf ebooks library BE final year project ideas Embedded systems