poitsplace wrote: > According to the datasheet, the value is latched from the EA pin at > reset...so the only way to do it on the fly is to have the CPU put > everything in memory first...then reset. If it looks like the > hardware to change the EA pin and reset the CPU (on the fly) is goint > to take too much space you might do well to simply use a 2k > flash/eeprom chip. That's enough for a boot loader. Just remembering that "RESET" here stated is literal, meaning "hardware reset". Some people could confuse it by just jumping to address zero. That is much easier than you can think. A bootloader could be implemented easily by just incorporating an external RAM (and the address decoder) to the unit, wired as data and code. The bootloader is an internal software that its only job is to monitor the internal UART, dealing with transmission from an external source, your PC, sending the new code to be run on this target uC. The bootloader will move the incoming binary data to the external RAM, now acting as a regular external data memory. Upon the PC transmission is finished, all the new code (to run and test) is already in the external RAM, and if the uC could address external code, will run that code, since the external RAM is wired to be accessed as data (for read and write) and as well as code (as an eprom). The point is that when powering up the uC, or by manual selection, the internal code should first run, the bootloader. Then, after the code is downloaded, it should run the external code. This is selected by the /EA pin as discussed. There are several ways to do that, selecting /EA high or low. You can even do it manually with a simple SPDT switch, that is the easiest way to do. Turn the switch to /EA high, press reset, bootloader takes place. Once the new code is downloaded to the external RAM, turn the switch to /EA low, press reset, your new test code will be running. Another way is to use an external flip-flop, as a 74HC74, using few pins of the uC to switch the 74HC74 that will hold the new level for the /EA and at the same time a pulse to reset. But I like the easy idea of using a capacitor. Connecting a small 10uF capacitor between +VCC and /EA is enough, and that is all it takes. Upon power up, the capacitor is discharged, so at reset, /EA will be close to VCC value and dropping fast, but not fast as the reset that will be using a 1uF capacitor. So, during RESET the /EA will be at high level. It is latched internally and internal code is choosen, thus, the bootloader takes place. During the few dozens milliseconds that follows, the 10uF capacitor (or any other value you find appropriate) will be charging to almost the whole VCC span, so it takes /EA down close to ground. It doesn't matter if the bootloader already downloaded the code from the PC or not, the uC continue to run internally until the next reset. So, even if after half an hour later the PC sends the test code to the uC's RAM, it will still runing in internal code, and after that download completion, the bootloader issues a port pin to issues a brief reset pulse to itself, reseting the uC, but now, the /EA is forced down via the capacitor. Guess what? external code now is selected and the test code stored at the RAM takes place. A second switch installed in paralel to the capacitor can be used to dischage it and copy a pulse to reset, so it is a forced way to call back the bootloader for further downloads... Easy and simple. Difficult combination to happens. Wagner Lipnharski - email: wagner@ustr.net UST Research Inc. - Development Director http://www.ustr.net - Orlando Florida 32837 Licensed Consultant Atmel AVR _/_/_/_/_/_/
Message
Re: [AVR-Chat] Re: How to use /EA-Vpp pin?
2004-02-09 by Wagner Lipnharski
Attachments
- No local attachments were found for this message.