Attempting to create my own 'trainer' board for 8051/52 microcontroller. - Page 1
Forum section: electronics / beginners

author: SittingBear
author_rank: Contributor
timestamp: October 22, 2014, 05:38:46 am
content: I will be using Atmel's low-price version of the 8051/52 called the AT89LP51 (datasheet).Due to wanting to program this over USB, I was hoping to simply use the USB to Serial (UART) converter found on my Arduino board via Tera Term or other terminal emulators. I have an idea for a schematic for the entire circuit up until it comes to how to program it properly. The datasheet mentions some specific user-programmable fuses and other neat features, but I'm really worried about being able to properly clock RX/TX data to the thing from my computer's USB. I could also build my own programmer or use another one already available.What I'm really asking is, what do I need to do with the microcontroller's clock frequency and my USB-to-UART converter to ensure I can properly program / communicate with the microcontroller?Any advice is greatly appreciated!

author: Jeroen3
author_rank: Super Contributor
timestamp: October 22, 2014, 08:19:19 am
content: uart is usually asynchronous unless you explicitly include a clock line to make is synchronous (mostly found with inter-processor communications). You only need to pay attention to the accuracy of the two clocks, and use a baud rate which allows a certain percentage of clock error in the entire length of the one frame (start to stop bit).Put more effort in the handshaking (rts/cts) to make sure you're not overflowing the microcontroller since USB is block based.

author: westfw
author_rank: Super Contributor
timestamp: October 22, 2014, 08:49:55 am
content: It looks to me like you'll need something (very) similar to the ArduinoISP sketch to program the 89LP51. That should be fairly independent of clock speed, but it will require code on your arduino rather than just the usb/serial converter.

author: Jeroen3
author_rank: Super Contributor
timestamp: October 22, 2014, 09:44:38 am
content: Yes, you will need to initially ISP in the bootloader. Newer ARM's are usually equipped with bootrom for various interfaces.I always prefer an ISP or SWD/JTAG programmer over an DFU interface. Since it is usually faster and more reliable. However also more expensive.

author: Simon
author_rank: Unknown
timestamp: October 22, 2014, 11:57:30 am
content: You can of course just use an FTDI cable.

author: SittingBear
author_rank: Contributor
timestamp: October 23, 2014, 12:17:57 am
content: Quote from: Jeroen3 on October 22, 2014, 08:19:19 amThis is good to know, I will look at resources to learn more about the UART communication of RX and TX. If you know of any specific tutorials or write-ups I'd love to take a look! Thank you for this.Quote from: westfw on October 22, 2014, 08:49:55 amAfter reading over the datasheet and seeing other replies, you are right in that I could use SPI to program the 89LP51 so long as I handle everything correctly. I could then either have the HEX file hard-coded on the Arduino every time I want to send a new program to the 8051 or send it to the Arduino over Serial communication to then be programmed to the 8051. Thanks!Quote from: Jeroen3 on October 22, 2014, 09:44:38 amGood to know! I will try to go with what's easiest for me to understand and work from there.

author: amyk
author_rank: Super Contributor
timestamp: October 23, 2014, 03:00:44 am
content: Quote from: Simon on October 22, 2014, 11:57:30 amProvided it's a real one, of course.

author: SittingBear
author_rank: Contributor
timestamp: October 23, 2014, 05:52:22 am
content: Quote from: amyk on October 23, 2014, 03:00:44 amAfter further pouring over the datasheet, I decided I will build a dedicated ATMEGA16U4 circuit as it directly interfaces with USB. This will be my dedicated 8051 programmer board via SPI. Since I am very comfortable with the Arduino and find it very easy to make a quick serial-communication program using C#, this will be perfect. It also helps that the datasheet for the Atmel 8051 I linked in the original post has a very detailed chapter on how to program the microcontroller via SPI (see page 84). This way I do not have to worry about baud rates or clock speeds so long as I don't go too fast allowing me to choose a 16MHz or 20MHz (max) crystal oscillator. All in all this is a perfect solution as it's very easy for me to do and will be easy to debug as well.I'd say at this point I have found my solution to this concern

author: westfw
author_rank: Super Contributor
timestamp: October 23, 2014, 08:16:52 am
content: (this is what happens every time I try to design an 8051 board. I end up putting "smarts" on the board that are are smarter (and more expensive) than the 8051, and then think "what's the point?")Let us know if you get further than that. I still feel like I should have a few 8051 boards of some kind sitting on my shelf...

author: SittingBear
author_rank: Contributor
timestamp: October 23, 2014, 01:52:23 pm
content: Quote from: westfw on October 23, 2014, 08:16:52 amEven though I could just use newer microcontrollers, I very much like the way the 8051 works and it's syntax. It's the must fun microcontroller I've ever played with so far. I tried taking a stab at programming AVRs using assembler, but it was a bit too complex and foreign to me so maybe I'll try it again in the future. I want to use assembly, because I find it fun and easy to understand (for the 8051). I could also use the PIC I'm sure, but I choose not to.

author: Jeroen3
author_rank: Super Contributor
timestamp: October 24, 2014, 05:25:57 am
content: Both AVR and 8051 are deprecated imho. Get an ARM Cortex MHowever, an ISP programmer for AVR or 8051 isn't that expensive, is it? Why not a ISP header on the board? Also put on an FTDI chip (instead of an old D-sub), the new FT230X is nice. Always helpful for debug, since stepping and breakpoints are limited in AVR and 8051.

author: westfw
author_rank: Super Contributor
timestamp: October 24, 2014, 08:13:14 am
content: QuoteIt depends. Traditional 8051 chips (like the ones I have lying around) don't have ISP, so programming them involves ~24 connections worth of parallel programming :-(So the first depressing thing that you decide is that you should probably throw those away and spend the whole $2 on one of those newer chips with ISP... (and throw away that UV eraser as well!)

author: Scrts
author_rank: Frequent Contributor
timestamp: October 24, 2014, 10:42:13 am
content: I've just double checked if the OP post wasn't posted in 1994...