Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Question about PC-PIC-EEPROM transfer

Status
Not open for further replies.

deniah

Member level 4
Joined
Nov 28, 2005
Messages
74
Helped
6
Reputation
12
Reaction score
5
Trophy points
1,288
Location
Montenegro
Activity points
1,777
Hello to all

I need some help with my project. I need to transfer 16 kb of data to 24C128 thru PIC. MCU is 16F872. Eeprom is attached to pic on RC3 and RC4 and i'm using I2C library. PC-PIC communication should be with hardware USART.
I'm not quite clear how to do this. Do I need to enable interrupt on USART receive? How to send data from PC and proceed to the eeprom? Can data be send to PIC like a streem (all 16kb)? What if one byte is received but previous byte writing procedure is not finished? Can some data be lost during write eeprom procedure?

Thanks in advance
 

I think you are on the right track.
I would say it is absolutely essential to use USART receive interrupts, otherwise you will be constantly trying to poll the USART when you could be writing to the EEPROM. I suggest you also look at using the SSPIF interrupt to tell you when I2C data has been written as well. My first thoughts on the solution are that as the EEPROM write sequence is relatively slow and you are probably wanting to use a relatively fast Baud rate, you need to do some buffering and handshaking with the PC. I would tackle it this way:
1. allocate a buffer area in PIC RAM
2. receive and store USART data in the buffer.
3. when the buffer reaches about 80% full, signal back to the PC to stop sending, this can be with the CTS line or using XON/XOFF ASCII codes.
4. write the buffer data to the EEPROM, remember it increments its internal address after each write cycle so you only have to send the address once at the beginning, after that only send the data.
5. when the buffer has emptied, tell the PC to send the next block of data and go back to step 2.

If you need it to work as fast as possible, you can implement a circular buffer and overlap the receive and writing operations to some extent but the code becomes far more complicated with only a small gain in speed.

Brian.
 

Thanks for suggestions. I look on MSDN and find some hints now to use CTS line. Speed is not critical, but integrity of data. For 20MHz xtal minimum baud rate allowed is 2400 so I will go with this.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top