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.
#define N M+5 Always( always( always ) ) use parenthesis.
#define N (( ((M)) + ((5)) )) // (over) (use) (them) (!)
Its in the book; on page( PARENTHESIS ) to be exact.
It would be quite interesting the see the full code monkey rule set.
Its basically standard stuff; a racy jacket, a steamy intro, the main characters are shallow, has a thin plot line, lots of typos, and has a dry, monotone-ish narration.
In the end you are either a satisfied or you're left needing more.
<excerpts from "Rules for Code Monkeys"...>
Thou shalt not use Hungarian Notation. Thou shalt not use 'internet' code; unless an assignment is due, and the teacher can't tell the difference anyway. Thou shalt not kill (depending upon the project specifications) Thou shalt not use the closing bracket ']' symbol without first declaring allegiance to King Kong or saying several "Hail Fay Wray"s. Thou shalt not ramble-on-and-on in forums. etc.
You know, the standard stuff.
--Cpt. Vince Foster 2nd Cannon Place Fort Marcy Park, VA
Yes, I know that you hate macros.
I felt that I had to write that example just because the people in most need of good advice about symbol names and sw comments are quite likely to do produce such #define'd constructs.
A #define'd expression without parentheses is definitely one of the mortal sins of programming - it doesn't matter if it is production code or just some test code.
Another is to hide the #define'd symbol by not using capital letters.
Or having a conditional #define that mucks up a dangling else. Or writing code that has a dangling else.
A define that makes use of a parameter more than once is also quite high up on the no-no list. And code that does call a #define while using ++, -- or similar modifying accesses on one or more of the parameters.
I haven't really decided what is the best way to get good developers. - Huge quantities of information. - Give people a bit of help into all kinds of traps and then have them learn why they got into the trap and how to avoid at least that speficic pot-hole in the future.
In the end, hands-on experience with problems is quite efficient. People tend to remember a broken nose far longer than they remember the text in a school book. And they don't doubt the real pain that results from doing something the wrong way. The trick is to not produce permanent damage so they switch to another profession, and not to produce permanent monetary loss.
Yes, I have seen
#define TEN 10
Now that is a real beaut.
I just hope it was from a very bright student who wanted to be a bit cheeky with his teacher.
I once saw some source code where the person didn't realize that decimal and hexadecimal is just different presentations of the same number, and that the C compiler supports hexadecimal constants.
So the code contained:
#define HEX_00 0 ... #define HEX_A0 160 #define HEX_A1 161 ... #define HEX_FF 255
Good to have in case he needed a hexadecimal number and forgot how to translate to decimal :)
Or maybe he had seen one of the binary declarations that exists here and there, and not realized that a header file with:
... BIN_0110_1001 0x69 BIN_0110_1010 0x6a ...
exists just because binary numbers aren't part of the standard language, while the compiler has very good hexadecimal support directly in the language standard.
So i have to use the delay function inorder for this to work? But how do I create a delay function with AT89S8252?
Next thing, How do i ensure that my development board is correctly connected other than using the blinking code for testing, are there any other code which i can use for testing?
Thirdly, I have use meridian software to connect the development board, But when i select COM1 port, the active light will go off and I cannot chose the device from the list. Is this normal?
The board that i am using is EQ-8051-ST1 is a AT89S8252 chip, which i see from the board.
Thou shalt not kill (depending upon the project specifications)
captain, what about the three rules of robotics... ;-)
They will not be introduced until the positronic brain has been released.
By the way. Asimov later extended with a fourth rule about the good of the many, to avoid freezing and permanently destroyed positronic brains ;)
and, of course, he later introduced the "zero law" as well.
ho, you meant that one!
About PCW, I want to know the hexa code for this thing so that i can configure the output of the port. Because I heard that I need to configure the port so that I can make the LED blink
What is PCW?
Your subject "RE: PCW" seem to imply a continuation of an earlier discussion, but PCW has not been mentioned anywhere earlier in this thread.
Are you talking about the PCW C compiler?
If a 'robot' implements Asimov's three Laws, its OS was most likely written by Microsoft, Apple, or Ben & Jerry's All Natural Coding Company.
Elsewhere, especially in the despot 3rd world like North Korea, or any communist country, Asimov's Law wouldn't be coded up with zeal.
The real-world variation to Isaac Asimov three laws of robotics is the "Kim Jung Mao Tse-Stalin" Three Laws of Robotics:
1. A robot may not injure a human being or, through inaction, allow a human being to come to harm. 2. All Robots are to comply with The Higher Utopian Government (THUG) 3. Rule 2 supersedes Rule 1.
My rule-book against [coding] radicals does have a Human Safety Factors Section. No reference to Isaac though.
Vince, You are the perfect warrior: Combining a poetic soul with cutting edge deadly accuracy...!
Thanks for the compliment (that helps with my 'ego troubles')
"cutting edge deadly accuracy"
You have no idea... oh, wait... here's some "Killer Apps" I wrote a while ago...
(No 8051s were harmed in the making of these films. If you are a Ti DSP fan, you might avert your eyes.)
(no, I don't work for Raytheon).
NOTE: 1.8MB video www.raytheon.com/.../cms04_022892.wmv CAUTION: LARGE FILE 36MB video... www.raytheon.com/.../rtn_rms_ps_excalibur_video2.wmv
Vince, Is this the new GPS guided artillery shell? I saw a TV program about it (I this is was on Discovery Science but I am not sure). They said something about the very high angle it hits its target, so that the bad guys cannot hide behind buildings!
"Is this the new GPS guided artillery shell?"
There are several of these GPS guided/assisted gun-launched systems. XM982 was only one of the trail-blazers. Don't forget: it has to be designed to handle the 'Howitzer' launch and balloting forces--you've heard of rugged-ized computers?
"I saw a TV program about it"
Yes, they've been on "Future Weapons" and other History / Discovery channel shows. XM982 gets most of the limelight right now.
The first video is a munition that hasn't been on those shows: yet (that I know of).
Its funny how I'll watch these shows and be surprised that they're showing 'my stuff.' (There are huge teams of engineers working on these, I think we all take total ownership of these projects).
There is usually a few years of lag between development and 'public release.' It used to be a lot longer, now its only a few years---uh well for some projects.
The high-angle thing is just one of many possible capabilities of these types of rounds. They can alter their trajectories to help prevent the enemy from knowing the launch points. In addition (the video sort of shows this, but you'd have to know it) you can launch them at staggered times and places, yet they can hit the target(s) 'simultaneously'.
The first video has IR capability: it can hit a moving target, so the GPS helps get to the target area while the IR does the terminal maneuvering. (the convoy on-the-move can still be shelled).
"...hide behind buildings!"
That type of high angle of attack allows the bad-guy bunker between the tall buildings get nailed. ...without also taking out the hospitals, day-care centers, shopping mall, code-monkey diploma mills, etc.
“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.
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
View all questions in Keil forum