??? 02/27/06 16:03 Read: times |
#110856 - about the code Responding to: ???'s previous message |
Hello guys,
I don't mean to hijack this thread, however I have been trying to do [almost] the same thing for a while now with no luck. I have read everything there is to read, and even purchased some 8051 books and have succeeded with many projects but I still have a few very minor questions, (PLEASE don't flame me, I know these questions may have risen in the past and some of you guys are probably getting frustrated - I don't blame you at all!.) What I am trying to do is a terminal run IIC or I2C (whatever)loader for a 24CXX eeprom. Without handshaking (I have seen this done many times before) I am sending a hex file to the loader. The software runs at 9600 baud @ 11.0592 and is interrupt driven. The ascii bytes go in the circular buffer from the terminal program. (Incidentally I checked the buffer with my simulator and it is working perfectly) All of the I2C write routines work perfectly. I can program random data into the eeprom, read it back and dump the data back to the terminal (using dmphex routine I found here) **So the main question I have is while the serial data bytes are going into the buffer during the interrupt, the program can still run doing something else like program the bytes into the eeprom? In the source code I downloaded, I get this: While polled transmit and receive can handle a great deal of applications, there are times when you may need for your micro controller to be doing something else while receiving
or transmitting data. This is where interrupt driven serial communications comes in. Interrupt driven serial routines involve much more overhead as far as program code size and RAM requirements, but have more flexibility to allow the micro controller to do other things while sending and/or receiving data, plus insurance that received information is less likely to be missed. **Next question: In the time it takes to write a byte to the eeprom, if an interrupt occurs (like in between a pulse, or when bits are shifted out) will it still process ok once the interrupt is complete? For the record, I am not using any registers/bits etc. that may be changed during the interrupt. The simple circular buffer routine uses r0 to store the byte to the buffer and I use R1 to read data from the buffer. The only thing the ISR saves is the acc. r1 reads the byte from the buffer and of course converts it to hex (atoh routine downloaded here) then programs the data. The buffer is held in ram @30h to 60h. The stack pointer is @ 70h. I am [almost]certain the buffer is not wrapping around. (after incrementing r0, IF r0 = @61h, it starts over @ 30h, and the data is overwritten.) ** so the LCD code posted in this thread is simlilar to what I am doing in the sense that data is being accepted into a circular buffer and then the data is read and processed. There is a time period until the next byte will be read from the buffer. If I use the polling method every 4rth line gets programmed in the eeprom, simply because the bytes are lost while the programming is executing. Any advice, pointers, etc. is well appreciated! This is simply a project I am doing in my spare time, just to learn more about 8051. I do not expect a handout, as this is a learning thing for me. The very well written pdf document "RS232gd.pdf" inspired me to restart this project again. Thanks all! |