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.

Programming 8051 microcontroller-AT89S8253

Status
Not open for further replies.

Nisushie

Newbie level 5
Joined
May 3, 2011
Messages
8
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,347
Hi!!
Can someone shed some light on my project?
I need to use Atmel AT89s8253 on this one.

Use AT89S8253 to countdown 1hr to 0.
display time mm:ss on 7 seg display.
once reach 0, buzzer sounds.

But my problem is that I do not know how to write up the program (since i am really new).
And I do not know how to connect up the circuit.

Can help please?:oops:
 

Then I have another question : I saw this chip AT89C51... it is similar to the AT89S8253 only that i think that the AT89S8253 has extra functions.
Lets say I have a circuit diagram and program used for AT89c51. But i used the AT89S8253 instead.. Can it work? Is there any factors that I should take note about?
**broken link removed**
 

When substituting MCU of the same family factors to look for are:

Pin Compatibility
Memory Sizes (Program, RAM, etc)
Operational Speed (Max Crystal Frequency)
Operating Voltage (5v, 3.3v, etc)
Peripherals (I2C, SPI, USART, etc)
Instruction Set (particularly if assembler routines exist)

These are most of the main factors to examine in the original MCU vs the replacement MCU.
 
The AT89S8253 microcontroller ID

* Compatible with 8051 family.
* 12Kb of Flash Memory for storing programs.
o Program is loaded via SPI System (Serial Peripheral Interface).
o Program may be loaded/erased up to 1000 times.
* 2Kb of EEPROM Memory.
* Power supply voltage: 4-6V.
* Operating clock frequency: 0-24MHz.
* 256 bytes of internal RAM for storing variables.
* 32 input/output pins.
* Three 16-bit timers/counters.
* 9 interrupt sources.
* 2 additional power saving modes (low-power idle and power-down mode).
* Programmable UART serial communication.
* Programmable watchdog timer.
* Three-level program memory lock
 

Sorry... Can someone explain this code to me? I don't understand the part where it starts with the MOV TH0 and MOV TL0..
erm.. I don't understand the -500 high byte and the -500 low byte...
ORG 8100H
MOV TMOD,#01H; 16 bit timer mode
MOV TH0,#0FEH; -500(high byte)
MOV TL0,#0CH; -500(Low byte)
SETB TR0; start timer
JNB TF0,WAIT ;wait for overflow
CLR TR0 ; stop timer
CLR TF0 ; clear timer overflow flag
CPL P1.0; toggle port bit
SJMP LOOP; repeat
END
 

Sorry... Can someone explain this code to me? I don't understand the part where it starts with the MOV TH0 and MOV TL0..
erm.. I don't understand the -500 high byte and the -500 low byte...
ORG 8100H
MOV TMOD,#01H; 16 bit timer mode
MOV TH0,#0FEH; -500(high byte)
MOV TL0,#0CH; -500(Low byte)
SETB TR0; start timer
JNB TF0,WAIT ;wait for overflow
CLR TR0 ; stop timer
CLR TF0 ; clear timer overflow flag
CPL P1.0; toggle port bit
SJMP LOOP; repeat
END

MOV TMOD,#01H; 16 bit timer mode
It means the timer has now two bytes for its counter; TH0 (higher byte) and TL0 (lower byte), both form one 16-bit counter.
Let us suppose the crystal frequency is 12 MHz. The instruction cycle needs 12 pulses of the MCU oscillator, so the period of one cycle is 1/ (12MHz/12) = 1 µsec in this case.

If we let TH0=TL0=0 then for the Timer 0 to reach its overflow it has to count from 0 up to 65535 (FFFFh) and the next count will set the overflow flag TF0. So if TH0=TL0=0, we will wait 65536 µsec for TF0 be set.

But if we need the interval be just 500 µsec for example, what can we do?
We have to load TH0 and TL0 with a 16-bit number which is lower than 65536 by 500.
In other words, we need to load them with a number = 65536 - 500. But for 2-byte calculation the number 65536 = 0. Why?!
If we write in hex, 65536 = 10000h hence it is formed by 3 bytes 1h, 00h, 00h. But since we are working with 2 bytes only, the most significant byte is dropped... and what remains is just a ZERO :wink:
So we can re-write 65536 - 500 as 0 - 500 which gives just -500. Fortunately the compiler (or assembler) knows in advance that we are working with 2-byte system so it also understands if we write -500 and calculates it as 65536 - 500 = 65036. Obviously 65036 is also 2 bytes (FE0Ch), TH0 will take its high one (FEh) and TL0 its low one (0Ch).
(If you are familiar with two's complement, -500 is the two's complement of 500).

Kerim


Edited:

I usually write this in my assembly program:

#define lo(arg) (arg)&0FFH
#define hi(arg) (arg)/256

then for example:

MOV TH0,#hi(-500) ; equivalent to MOV TH0,#0FEH
MOV TL0,#lo(-500) ; equivalent to MOV TL0,#00CH

This helps me avoid finding 0FEh and 00Ch manually.
 
Last edited:
How is your project coming along Nisushie? Did any of the links I posted, help you get started?

Have you determined a code sequence that satisfies your design requirements, a flow chart perhaps?
 

How is your project coming along Nisushie? Did any of the links I posted, help you get started?

Have you determined a code sequence that satisfies your design requirements, a flow chart perhaps?

I've went through the list and they give a lot of infos but my brain is slow... hAHAHAH
so basically i've done a bit of codes here and there and the above is one of them.. but yeah im not getting good at it..
And for the above code I want to change the values to 1hour.
Tried to coppy other projects but well it didnt work so the best thing is to just do on your own. at least I know where goes wrong.. haha

Plus I need to create a circuit diagram to show the output at 7 segment display to show the time counting down. *bimbo mode*

But thanks biddogguru n Kerim!!!
 

Now I have a problem...
Due to my super inexperience in 8051, i was told to use C programming (my teacher said).
He suggested that I should use PIC18F4550.
Now I want to know, since we need to declare variables and such, how should I declare if my input is from an outside source??
 

He suggested that I should use PIC18F4550.
Now I want to know, since we need to declare variables and such, how should I declare if my input is from an outside source??

I'm not understanding your question. Can you give an example situation; are you still referring to a timer project?
 

    V

    Points: 2
    Helpful Answer Positive Rating
Bigdogguru:
Yes, my timer circuit...:twisted: Assembly language is hard so I was told to use C programming (PIC18F4550).

Other than assigning the ports, we have to declare variables right?
My question is how to declare variables if i need to get signal from another chip.
Im using TDA0161 chip.
That signal from chip is going to trigger my PIC chip timer...


Suddenly I feel my project is very complicated... Wouldn't it be easier if i were to just use an OMRON timer...? :-?
 

Have you already designed the circuit and interface for the TDA0161?

Do you have the skills to design the interface?

If not you may want to consider purchasing one of these:



It would simply your situation and allow you to concentrate on the program design.

Interfacing the ZX-Metal-Board with the 8051 would be fairly easy.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top