i have problem with the led blinking. I using the exmaple program given by keil using uVision3. When i run the program, the LED on the development board didnt blink, it just stay on! wat should i do?
thanks!
O ok because i have search some of the thread that says that using loop will do the job. But after that I try to search again and found out that having loop wont do as well as timer.
I am now using AT89S8252, product code is EQ-8051-ST1 which come with the development board and a programmer board. at the development board there are 8 LED, can these LED be control by the coding that I have done. Or is there other way other than blinking, can test out whether the board is working fine. I would prefer with C code.
Thanks You
1) Do not use the name wait() for your function. All it tells is some magic waiting (is expected to) happen, but not what wait. Waiting for a key press? Waiting for the supply voltage to stabilize? Waiting a specific time?
Since you are talking about a time delay, change the name so that it clearly says exactly how long the delay is. Optionally modify it to take a parameter to specify how many such time "clicks" the function will wait.
For example:
delay_10ms(25); // Delay 250 ms delay_1s(20); // Delay 20 seconds delay_us(2700); // Delay 2700 us
2: You normally don't encapsulate all use of a timer into the delay function. You often initializes the timer once from main() and then you either use the timer in free-running mode, or clears the counter value ... (depending on how you choose to impelement the delay and the capabilities of the timers in your specific processor) in the delay function.
You want a delay function to have as little setup time as possible so that it may also contain a loop to handle n delay steps. With a lot of initial setup, the length of the first and the following ticks may be different.
“I Am Become Death, The Shatterer Of Worlds"
Vince, I hope you were not offended by this famous quote. It was meant as a compliment! By the way, for the sake of the ill-informed, "I Am Become Death, The Shatterer Of Worlds" is a quote from the Bhagavad Gita, uttered by Robert Oppenheimer 63 years ago today, on the occasion of the first nuclear weapon's test in New Mexico. It just crossed my mind.
Gita outta here! No offense taken.
But don't give Oppenheimer a Baum rap. He ensured that the good guys (aka USA) had it first.
--Cpt. Vince Foster 2nd Cannon Place Fort Marcy Park, VA
Hmm no such thing? So is there any hexa code for port 1 or 2 of the development board so that i can enable the port to send output to the LED
So is there any hexa code for port 1 or 2 of the development board so that i can enable the port to send output to the LED depends on current requirements depends on LED configuration depends on ...
Erik
"So is there any hexa code for port 1 or 2 [...]"
I somehow get the impression that the language fools you. This is not similar to a "cheat code" or "access code" that you get from someone and that allows you to activate a new feature.
Hexadecimal numbers are just a different way of writing a number. No need to use hexadecimal numbers. An 8-bit port can handle a number between 0 and 255 (8 bits represents 2^8 = 256 states).
You must know what you have connected to different pins of a port. Then you must calculate what number to write to the port to tell if a pin is input or output. And you must calculate what pins to drive high or low. And you must calculate what pins you are interested in when reading a port.
Note that your processor pins may not require any special setting to change the individual pins between input or output. But your datasheet will tell you.
And you have still not told what your PCW is?
Hell, maybe PSW (does it even exist on a C51...?)
Sorry it should be control word, not PCW. Hmm can tell me where to find the formular to calculate the whether the pin is input or output?
Yes. The formula is simple:
a*1 + b*2 + c*4 + d*8 + e*16 + f*32 + g*64 + h*128
You have eight bits. Each having a bit position, i.e. a value of 1, 2, 4, 8, 16, 32, 64 or 128. The datasheet will tell what happens if you write a one or a zero to the bit. And it will tell if the relevant port has a data direction register, or if it only supports a open-drain transistor with a weak pull-up.
Now add together the relevant bit values. You do not post and ask how to sum the money to pay at the cafeteria. No need to ask how to sum the individual bits for the I/O ports either. And you should also be able to find a huge amount of sample code that shows how to use port pins as inputs and/or outputs. How much time have you spent reading datasheets and code in the week since this thread started? You should be quite comfortable with this by now.
oo so this formula is a representation of CW right? which determine which port is input and which port is output rite? thanks alot!
i saw this digram on how control word works. Link: www.sharpmz.org/.../8255ovview.htm
It says that the bit can control which port to work. So do i need to use binary for the program or just use hexadecimal/decimal will do?
One more thing, my data sheet does not clearly tell which hexadecimal is for control work. Because without the hexadecimal for the CW, i am not able to program the port using the formula that u gave me.
wait.... the hexadecimal/name for LED is it P1_0? or is this for the port pin? if this is for the port pin, anyone know where to get control the LED light?
Please refer to the following resources. They will answer your questions fully. You really cannot expect to make progress without knowing the very based stuff.
Chapter 1 www.semiconductors.philips.com/.../80C51_FAM_ARCH_1.pdf
chapter 2 www.semiconductors.philips.com/.../80C51_FAM_PROG_GUIDE_1.pdf
chapter 3 www.semiconductors.philips.com/.../80C51_FAM_HARDWARE_1.pdf
That link refers to an 8255 chip.
You have never mentioned before that you are using an 8255 chip.
How is anyone supposed to guess what chips you might be using if you don't say?
If you want to use an 8255 chip then, in addition to studying the 8051 and how to use it, you are also going to have to spend time studying the 8255 chip and how to use it.
It seems that you haven't even mastered the basics of the 8051 yet - so you really shouldn't be messing about with the added complications of an 8255 at this point!
Again, the basics for the 8051 are in the so-called "bible":
Chapter 1 - 80C51 Family Architecture: www.nxp.com/.../80C51_FAM_ARCH_1.pdf
Chapter 2 - 80C51 Family Programmer's Guide and Instruction Set: www.nxp.com/.../80C51_FAM_PROG_GUIDE_1.pdf
Chapter 3 - 80C51 Family Hardware Description: www.nxp.com/.../80C51_FAM_HARDWARE_1.pdf
For a tutorial on the basics of the 8051 - including how the ports work - see: www.8052.com/tutorial.phtml
There is a whole section about 8051 port IO at http://www.8052.com/faqs - in particular, see: www.8052.com/.../120176
And, of course, the book lists: http://www.keil.com/books/8051books.asp www.8052.com/books.phtml
That link refers to an 8255 chip. not for beginners (and not for advanced either, unless you are an anachronism) In the olden days the 8255 had its merits; however today all uCs outrun the 8255 and, in addition to the crummy interface, you will get timing problems.
Of course, you 'can' use a 2MHz crystal or such, but what's the point?
View all questions in Keil forum