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

Send file to PIC (SD card) through PIC

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



Joined: 19 May 2009
Posts: 60

View user's profile Send private message

Send file to PIC (SD card) through PIC
PostPosted: Mon May 23, 2011 7:34 am     Reply with quote

Lately I've been developing a sound and light unit for RC cars. There are 2 PICs on the board.

One PIC16 that is the master for the lights and reading of the servo signal inputs.
One PIC18 that does all the sound processing. This pic has a micro sd slot connected to it, I use the Smallridge driver.

The master PIC is connected to an FT232RL so I have USB. The TX of the master pic is also connected to the RX of the sound pic.

There are 2 more I/O connections between the PICs for random use.

All works well but there is one more thing I would like to implement.
I would like to be able to put a new sound file on the SD card. That means I would have to send the data to the first pic wich would send it the second one. Cause there is no communication from the sound to the light pic I guess I would need software UART communication.

Is this do able ? Or should I leave it for what it is. I can not change the HW design.

I know this would be very slow but that is always better than having to get the board out of the car.
temtronic



Joined: 01 Jul 2010
Posts: 9225
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Mon May 23, 2011 9:11 am     Reply with quote

Yes it's doable..even if there's only 1 I/O Pin on each PIC. CCS has interPIC examples in their examples folder.
You can probably get 250KBaud InterPIC speed, depending on how you handle buffers,checksums,PIC xtals,etc.
I'd write the code in 'blocks'.First get a PC that has the data file to communicate with the first PIC,have it loopback the data.Then add on the ability for the first to send that data to the secon, and have it loopback teh data to the first,which sends it to the PC.When that all works, then add on the actual 2nd PIC to memory card interface.
1-2-3 and you're done.
Skirmitt



Joined: 19 May 2009
Posts: 60

View user's profile Send private message

PostPosted: Mon May 23, 2011 2:18 pm     Reply with quote

Interpic, I never heard of that actually. Can't seem to find more info. But I get what you mean.
If I have the PC to send a buffer of 40 bytes for example, what is the command for the PIC to receive it then ?

Do I have to do a getc() in a loop with kbhit until I have received the 40 byte ?
Skirmitt



Joined: 19 May 2009
Posts: 60

View user's profile Send private message

PostPosted: Mon Jun 06, 2011 1:39 am     Reply with quote

First things first. I'll do the master "echo" terminal first.
What would be the fastest to do ?

Sending a string of data to the pic and letting it echo back or should I work byte per byte so on each getc() a putc().

I think working per byte is the most reliable and less chances for errors.
temtronic



Joined: 01 Jul 2010
Posts: 9225
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Mon Jun 06, 2011 7:30 am     Reply with quote

Check out the CCS example 'ex_sisr.c' in the examples folder for a 'circular buffer' routine. Make the buffer /2 (32,64,128) for best results(speed !). There's also a transmit version as well.....Put both routines in both PICs for best performance.

InterPIC was a 'system/software' that was developed 15-20 years ago when 'fast' PICs were 4 MHz! One 18 pin PIC replaced a 4"x6" pcb filled with 4000 series CMos chips. It allowed fast, bidirectional, interlaced communications between several PICs using only 1 I/O pin. As with all communications, there is a speed vs. distance trade off but you could get over 15 miles (yes, miles) at a slow bitrate. The nice thing was very, very low overhead and high security the exact opposite of today's 'modern' technology.
Skirmitt



Joined: 19 May 2009
Posts: 60

View user's profile Send private message

PostPosted: Mon Jun 06, 2011 12:25 pm     Reply with quote

thanks for your answer, it is very useful. I looked at the example and the code is very clear to me, I can work with this further. It will keep me busy for a while Very Happy
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