CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

16F1459 - CDC - HID - EEPROM - Transfer Data

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
jjacob



Joined: 08 Mar 2008
Posts: 54
Location: PORTUGAL (PORTO)

View user's profile Send private message

16F1459 - CDC - HID - EEPROM - Transfer Data
PostPosted: Fri Mar 17, 2017 4:18 am     Reply with quote

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: 19499

View user's profile Send private message

PostPosted: Fri Mar 17, 2017 5:30 am     Reply with quote

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: 1907

View user's profile Send private message

PostPosted: Fri Mar 17, 2017 6:18 am     Reply with quote

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: 9221
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Fri Mar 17, 2017 6:26 pm     Reply with quote

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)

View user's profile Send private message

PostPosted: Wed Apr 05, 2017 4:11 am     Reply with quote

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: 19499

View user's profile Send private message

PostPosted: Wed Apr 05, 2017 7:36 am     Reply with quote

Good. Well done. Smile

Nice to have a positive update.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group