View previous topic :: View next topic |
Author |
Message |
jjacob
Joined: 08 Mar 2008 Posts: 54 Location: PORTUGAL (PORTO)
|
16F1459 - CDC - HID - EEPROM - Transfer Data |
Posted: Fri Mar 17, 2017 4:18 am |
|
|
Hello,
I'm working at a project that involves transfer data (14KBytes of data, list of clients) from a PC to a EEPROM 24LC256, through 16F1459.
I already have it working: keyboard hid + cdc + eeprom, using ccs examples, like 24256.c and ex_usb_keyboard.c.
Now i'm trying to do the transfer of data from PC to 16F1459, and then write it to 24LC256.
For now I'm only transferring one byte at a time.
PC send one byte -> 16F1459 receives one byte, then 16F1459 write one byte on 24LC256.
Is there any way to do this in blocks? Is there some example in CCs? Can you point me the right path?
I appreciate all the help,
best regards |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19529
|
|
Posted: Fri Mar 17, 2017 5:30 am |
|
|
Look at the USB bootloader examples.
These are basically doing the same thing, but to the flash memory inside the PIC. You will see that they assemble a complete 'block' of data, then use flow control to tell the PC to stop for a moment, and store this.
You will need something similar, since the EEPROM is very slow to write....
Now block write on the EEPROM itself is easy. You just send it the start address of the block, just as for a normal write, and then where you would send a single byte normally, you just keep sending data (64 bytes max), and then stop as normal. The chip then performs a page write, instead of the single byte write. So you'd need to use a 64byte buffer. |
|
|
newguy
Joined: 24 Jun 2004 Posts: 1908
|
|
Posted: Fri Mar 17, 2017 6:18 am |
|
|
I'd recommend that you make the transfer robust. If you do things simplistically, for instance simply "dump" all values to the PIC from the PC, what happens if a character/byte from the PC is garbage?
Add some "handshaking".
PC: "Are you there?"
PIC: "Yes. Status: ready for data."
PC: "Transfer to follow. 28 bytes. Store beginning at address 0xd0"
or
PC: "Read 16 bytes, start address 0x14. Transmit immediately."
Etc. Ensure that you also add some sort of CRC or other error checking to each interaction so that either the PC or the PIC can detect bad packets. Obviously your handshaking won't be so verbose, but you would benefit from some sort of protocol. |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9232 Location: Greensville,Ontario
|
|
Posted: Fri Mar 17, 2017 6:26 pm |
|
|
It might be an idea to transmit data in 64 byte 'blocks' since that's the biggest size the EEPROM likes to store in a 'chunk'. It might reduce overall time and simplify the actual transfer. Assuming the EEPROM has a 'ready flag', you could use that for the handshake signal to the PC to send the next block of data.
just an idea...
Jay |
|
|
jjacob
Joined: 08 Mar 2008 Posts: 54 Location: PORTUGAL (PORTO)
|
|
Posted: Wed Apr 05, 2017 4:11 am |
|
|
Hello,
Thank you all for your help. It's solved.
I have used 64 bytes block transfer (eeprom page write), and have implemented a simple protocol with handshaking with PC. The CCS bootloader examples were very helpfull. |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19529
|
|
Posted: Wed Apr 05, 2017 7:36 am |
|
|
Good. Well done.
Nice to have a positive update. |
|
|
|