Discussion in "Project Help" started by    mem    Aug 30, 2008.
Sun Aug 31 2008, 01:42 PM
#11


hi mem,
looks like u are finally getting the basics of 8051 computing right. .
fine, here is a method to turn on/off the port pins individually without affecting the other pins of the same port;
say u want to turn ON the LED (clear the bit) at the port P0.4, then use the following instruction:
PORT0 & = ~(1<< 4);
to turn OFF the LED (set the bit), use the following:
PORT0 |= (1<<4);

pdi33


Thanks, I have been playing around some more and hit yet another wall, I thought your tip might help but it just replicates the same issue.
I can turn off LEDS 1&2 by setting P0 to 0x01 and 0x02 respectively.
Setting P0 to 0x04 which should turn off LED 3 instead causes all LEDS to blink rapidly. Same behavior on all my 4 chips (thought I may have blown one).

code below is using your example (all LEDS blinking rapidly):
#include < REGX51.H >
 
void main( void )
{
	P0 |= (1<<4);
	while(1)
	{
	}
}


My code that fails (all LEDS blinking rapidly):
#include < REGX51.H >
    
void main( void )
{
	P0 = 0x04;
	while(1)
	{
	}
}


My code that correctly turns off LED 1:
#include < REGX51.H >
    
void main( void )
{
	P0 = 0x01;
	while(1)
	{
	}
}

Sun Aug 31 2008, 06:17 PM
#12
hi mem,
do not worry bro, actually i think there is nothing wrong with ur code (both of them ) and will work just as good. the problem i think lies in ur hardware where u have to connect the EA/VPP to VCC for ur code to work properly. (u were plain lucky that the previous code did work!!!).
do that and give feedback. (Ur doubt certainly confused me for some time until i cross checked in detail ur ciruit in the previous post!!)
good luck :-)
In ur code:
P0 | = (1<<4);
u will have to add this statement before that :
P0 = 0x00 ;
to make it equivalent to ur other code because in the former case, the state of P0 will be 0xff (only in case of 89c51 and not guaranteed in case of 89s51!!).
 mem like this.
Mon Sep 01 2008, 01:57 AM
#13

i think lies in ur hardware where u have to connect the EA/VPP to VCC for ur code to work properly. (u were plain lucky that the previous code did work!!!).
~snip~
In ur code:
P0 | = (1<<4);
u will have to add this statement before that :
P0 = 0x00 ;
to make it equivalent to ur other code because in the former case, the state of P0 will be 0xff (only in case of 89c51 and not guaranteed in case of 89s51!!).

pdi33



Thanks mate, I read through the pdf again after reading the info you provided and it does seem Im 1 wire short.

PDF EA/VPP Pin info:


I will update my circut (and diagram) and test once Im home today. Thanks very much for you help.

Updated Diagram:


[ Edited Mon Sep 01 2008, 02:41 AM ]
Mon Sep 01 2008, 08:43 AM
#14
Thanks very much pdl33. That was indeed the issue and no doubt it would have taken me quite awhile to sort it out. Here is my final code that I used.

/*
Target chip: AT89C51
IDE: Keil (startup code)

This project is written in Keil by Jacob Jarick
[email protected]

Pattern Table:

HEX	DEC	0 1 2 3 4 5 6 7

0x03	2	1 1 0 0 0 0 0 0
0x06	6	0 1 1 0 0 0 0 0
0x0C	12	0 0 1 1 0 0 0 0
0x18	24	0 0 0 1 1 0 0 0
0x30	48	0 0 0 0 1 1 0 0
0x60	96	0 0 0 0 0 1 1 0
0xC0	64	0 0 0 0 0 0 1 1
0x81	65	1 0 0 0 0 0 0 1

*/

#include <REGX51.H>
#include <intrins.h>
	// provides _nop_

char const num[  ] = {0x03, 0x06, 0x0C, 0x18, 0x30, 0x60, 0xC0, 0x81 }; 

void wait ()
{
	unsigned int c;
	for(c=0;c<50000;c++)
	{
		_nop_();
	}
}
	   
void main( void )
{
	unsigned char j;
	P0 = 0x00;
	while(1)
	{
		for(  j = 0; j < 8; j++  )
		{
			P0 = num[j];
			wait();
		}
	}
}


Now to have some fun making different patterns.


[ Edited Mon Sep 01 2008, 07:47 PM ]
Mon Sep 01 2008, 06:24 PM
#15
good for u mem,
now i think u should explore the other features of 8051 as well like interrupts/timers etc. they always come in handy when u jump to some advanced application.
good luck
 mem like this.
Tue Sep 02 2008, 12:23 AM
#16
Cheers , I think my next project will be to either: make port 1 control another 8 LED's or control existing 8 LED's via a PC serial/ parallel cable.
Would it be worth writing a how to for my LED chaser project ?, if so Id be more than happy to write one up for submission.
Tue Sep 02 2008, 03:05 AM
#17
the second option looks better. check the UART communication tutorial (tutorial section) on this site. It has a very simple explaination about the serial communication .and if u have any doubts u know where to post them .

wish u all the best . :bye .
 mem like this.

Get Social

Information

Powered by e107 Forum System

Conversation

Sun Apr 30 2017, 05:49 AM
Lijin G Varghese
Can u send me the circuit diagram for Program to interface GSM Module with 8051 microcontroller (AT89C51) using PC and LCD
Sun Apr 30 2017, 05:48 AM
Lijin G Varghese
Program to interface GSM Module with 8051 microcontroller (AT89C51) using PC and LCD
Fri Apr 28 2017, 03:47 PM
SANDEEP T S
I need pcb wizard 3.5 version kindly send valid link of yours
Fri Apr 28 2017, 03:46 PM
SANDEEP T S
I need pcb wizard 3.5 version
ExperimenterUK
Mon Apr 17 2017, 11:56 PM
Sorry..We had a problem with registration.Confirmation emails were not sent.Please re-register
Thu Apr 13 2017, 07:29 PM
Piyush Aughad
I want circuit & program for radar detection using Microcontroller 8051
Tue Apr 11 2017, 03:27 AM
Shabbir Ahmed
Hi Ajay ....hope you and your family all will be fine are you working on andriod aplications if yes then plz reply me
Sun Apr 09 2017, 06:33 PM
ATHULYA NAIR
Dear Sir, I need to know what are the complexity for programming in 8051 Microcontroller for three phase inverter?
Sun Apr 09 2017, 06:32 PM
ATHULYA NAIR
Dear Sir,
Sun Apr 09 2017, 04:43 AM
Rohit chandra joshi
Sir I need ur help urgently.i am trying to make pc controlled led scrolling display using 8051.when i am trying to generate hex file of the code that is given by pratik suthar.it gives the error Target not created Limit:0800h I am using keil uvision4 software. Even i have tried to burn the given hex file that is atteched with the code but my led are not glowing. Pls help me sir .i struck in this problem from last month and till now i am not able to short out the problem. Pls suggest me to solve the problem.mail me at [email protected] Thanks

Downloads

Comments

anshulece
Fri Apr 28 2017, 03:43 PM
Masoooud
Tue Apr 25 2017, 06:57 PM
BOuissal
Mon Apr 24 2017, 02:46 PM
tranhunga
Mon Apr 24 2017, 01:11 AM
Suslik
Sun Apr 23 2017, 09:26 AM
soumk
Sun Apr 23 2017, 06:22 AM
Vavachi1996
Tue Apr 18 2017, 08:01 PM
yasmine
Tue Apr 18 2017, 03:10 PM

Online

Guests: 59, Members: 0 ...

most ever online: 182184
(Members: , Guests: 182184) on 06 Aug 2010: 05:37 AM

Members: 37814
Newest member: anshulece
Forum Activity
Deepakvaishu Avatar
Posted By Deepakvaishu
Fri Apr 28 2017, 11:18 AM
Yes proteus is loaded ,with all projects.....Once ...
ExperimenterUK Avatar
Posted By ExperimenterUK
Fri Apr 28 2017, 05:06 AM
Does Proteus load at all ?Does it only crash on c...
Deepakvaishu Avatar
Posted By Deepakvaishu
Wed Apr 26 2017, 06:59 AM
hello...I am getting an error when I am trying to ...
ExperimenterUK Avatar
Posted By ExperimenterUK
Tue Apr 18 2017, 10:52 PM
Thanks for the comment.Glad you got it working.
Deepakvaishu Avatar
Posted By Deepakvaishu
Tue Apr 18 2017, 06:19 AM
Thank you very much...Today I got the output for a...
ExperimenterUK Avatar
Posted By ExperimenterUK
Thu Apr 06 2017, 05:38 PM
Is it initially assigned as '0', and then when the...
Deepakvaishu Avatar
Posted By Deepakvaishu
Thu Apr 06 2017, 07:55 AM
hello,Thanks for the attachment.I have gone throug...
ExperimenterUK Avatar
Posted By ExperimenterUK
Sat Mar 25 2017, 09:49 PM
I have attached code showing one method you could ...
Deepakvaishu Avatar
Posted By Deepakvaishu
Sat Mar 25 2017, 07:59 AM
I am using Keil and 8051 microcontroller
ExperimenterUK Avatar
Posted By ExperimenterUK
Fri Mar 24 2017, 06:05 PM
The best way is to use an interrupt to run the cou...