Re: The best way to learn programming AT89S52

NOTE ==> I added comp.arch.embedded and also set the follow-ups there. The c.a.e group has significantly more traffic that a.m.8, particularly since so many usenet providers have dropped all alt groups.

What is the best way to study programming the AT89S52 ?

Atmel's programmer for this part (which can also be used with their AVR chips but see [*]) is the AVRISP-2 (for example, at ) The programmer is run through Atmel's AVR Studio (for their AVR chips).

Other than the chip itself, what else you need kind of depends on what you have laying around. A minimum system would be a breadboard, power supply, and clock plus a few passives.

A 5-volt linear regulator (7805) plus a 9 V battery or unregulated 9 V DC wall wart (plus the usual few passives) is sufficient to power it.

If you need a clock, recommend a canned "clock oscillator" instead of a crystal; they're simpler to interface, fewer quirks. 24 MHz is common;

29.4912 MHz divides nicely for standard serial baud rates.

But you could also go with an RC oscillator.

I'm looking at the below - Atmel 89S52 study Experiment Development Demo >Board - which is also sold on Ebay for around $139 which is a lot of money >but will definately have a good ROI. I don't want to buy the Board if there >is better ways of getting grips of the Assembly language programming code.

A recommended "Step 1" is just to toggle a particular I/O pin in an endless loop. This looks simple but to get there requires getting a handle on basic architecture (what needs to be done to initialize?), the chip's registers (how to talk to the I/O pins?), assembling or compiling to loadable code, loading the code, and getting the chip to actually run.

Pseudocode start: initialization stuff outer_loop: toggle I/O pin set counter to 0 inner_loop: add 1 to counter if counter less than loop_max then goto inner_loop: else goto outer_loop:

Step 1.1 would be to toggle the I/O pin again, but this time using one of the chip's built-in timers. Set it to timeout at, say, a 2 Hz rate and toggle the I/O pin every time the timer fires.

start: initialization outer_loop if timer_event then reset timer_event toggle I/O pin goto outer_loop:

timer_interrupt_service_routine: set timer_event

This gets you into how to setup and service an interrupt.

Once you're to that point, everything else is (relatively) easy.

I was thining of maybe a software simulator or such which can maybe help - >if something like this exists. There is one on Ebay - PICKIT 1 Demo Board >(6LEDs) Based On PIC 12F629 - which is only for the 12F629. Is there maybe >something like this for the AT89XXX Series ?

Software simulators are dangerous unless they are 100% cycle-to-cycle identical to the behavior of the silicon. They're kind of useful to help in understanding assembler syntax, stepping through a couple of lines to see if it's what was expected. But for simulating a whole microcontroller? No thanks.

There is a lot of PDF's on the internet, but I need something more practical >where I can trial-and-error as I go.

The nice thing about a chip and a breadboard is that you can attach whatever you want to whatever you want (within reason).

For dev boards, the least expensive one out there looks like

which is only US$4.90 (yup, less than 5 bucks). They also have a $7 programmer (real serial port required) and $2 regulator.

[*] Regarding the AVR ISP and 89S52 programming. The AVRISP does work on both but it's complicated by the opposite polarities on the AVRs and 89S52 reset line. If it's used between the two families, it might (at least on the original serial port AVR ISP) not reset properly for the first programming cycle when changing to the 'other' chip family. No worries, just do it again and it should work.
--
Rich Webb     Norfolk, VA
Reply to
Rich Webb
Loading thread data ...

.

Good idea

emo

money

ere

e.

That's relatively expensive.

Also look at

formatting link
and their toolsticks. They have 5V models, typically at $9 for the stick, and $20+ for the USB portion,.these are well proven, and you get good USB debug.

On Atmel, look for their On-Chip-Debug parts and their newish AT89OCD-01 Software, which also has a related simulator.

The 89S52 is 'rather long in the tooth', and the newest Atmel silicon has on-chip debug. - rather than 89S52, using the AT89C51RE2, gives you On-Chip Debug in the same package (IIRC)

-

oard

be

True SW simulators are a useful 'second opinion', but once you have real silicon with the same environment, there is little point in thrashing a simulator.

-jg

Reply to
-jg

Thank you Rich - Much Appreciated

)
Reply to
Lodewicus Maas

Hi Jim

Did the AT89S52 not replace the AT89C51 ? I might be wrong, but I found a few google searches confirming this

Wicus

Good idea

That's relatively expensive.

Also look at

formatting link
and their toolsticks. They have 5V models, typically at $9 for the stick, and $20+ for the USB portion,.these are well proven, and you get good USB debug.

On Atmel, look for their On-Chip-Debug parts and their newish AT89OCD-01 Software, which also has a related simulator.

The 89S52 is 'rather long in the tooth', and the newest Atmel silicon has on-chip debug. - rather than 89S52, using the AT89C51RE2, gives you On-Chip Debug in the same package (IIRC)

True SW simulators are a useful 'second opinion', but once you have real silicon with the same environment, there is little point in thrashing a simulator.

-jg

Reply to
Lodewicus Maas

Yes, it did - and if you need a high volume, low cost, part without on Chip Debug, and can tolerate a 12 clock core, then the 89S52 is still good for new designs.

It's not the ideal part to learn on, as it lacks on chip debug.

The newer Atmel AT89LP series devices have single-clock cores, and better timers/spi peripherals.

-jg

Reply to
-jg

)

Look at

formatting link

Reply to
Neil

As a topical example of Q3 2009 devices, look at the new SiLabs C8051F560

- now in stock at Digikey. ToolStick Module is $10.50 (plus the TOOLSTICKBA @ $18.64) and you are ready to go. For that, you get 32K Flash, 2KR, 50 Mips, 12b ADC, 6 Ch 11b PWM, CAN, LIN, i2c, UART and on chip debug.

-jg

Reply to
-jg

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.