Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

In school I have written many programs for an 8051 compatible CPU. But I never actually knew how our "debug" sets worked. I mean, we test our programs in special sets, which actually allow you to very simply load program to CPU via PC serial port. But I think you know this much better than I.

But how does it work? I mean, I know there is a chip which adjusts signal level from PC serial port to TTL logic, and than connects to serial line of 8051. But that's all I know. Actually even my teacher doesn´t know how it works, since the school bought it all.

So, I suspect there is some program already running in the 8051 which handles communication and stores your program into memory, am I right? But, how can you make the 8051 process instructions from a different location than ROM? Becouse if I am right, you cannot write into ROM memory by any instruction, as well as 8051 can only read instructions from ROM?

share|improve this question

2 Answers 2

up vote 1 down vote accepted

The modern harvard-architecture MCU uses onboard flash memory to store firmware, so even though it's called ROM, it's not really read-only. According to the 8051's Wikipedia article, the modern 8051-based microcontroller often includes:

built-in reset timers with brown-out detection, on-chip oscillators, self-programmable Flash ROM program memory, bootloader code in ROM, EEPROM non-volatile data storage, I²C, SPI, and USB host interfaces, CAN or LIN bus, PWM generators, analog comparators, A/D and D/A converters, RTCs, extra counters and timers, in-circuit debugging facilities, more interrupt sources, and extra power saving modes.

The 8051 also has an onboard UART providing the serial port. It's been a while since I worked with embedded devices, but here's what I remember -- I worked with PIC microprocessors so this might not be exactly the way your 8051 does it:

  • On bootup, the MCU loads bootloader code from a particular ROM location.
  • Many common bootloaders will wait a few seconds, checking the serial port for a particular signal.
    • If you've attached the debug board to your computer's serial port, you can send that signal (with a terminal program like Hyperterm or Minicom, or with a special-purpose firmware loading program).
    • On receiving that signal, the MCU's bootloader code puts the board into programming mode, and you can send over the new firmware.
  • If the MCU doesn't get the signal, it continues booting normally into whatever firmware is already loaded in the program memory.

"Programming mode" on some microcontrollers involves using higher voltages to program EEPROM memory, but not all microcontrollers require this.

For specific details, you should refer to your MCU's datasheet (generally available from the manufacturer's website). The Stack Exchange site ChipHacker is dedicated to DIY embedded electronics and is a good place for further questions.

share|improve this answer

Yep, ROM is actually EEPROM or flash. So it is read-write. Also, your demo board could have external memory banks to store programs, and a boot loader to run stored program and handle PC communication to allow you to upload new program.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.