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

Byte error rate 10% with SPI
Goto page Previous  1, 2
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
lglenat



Joined: 08 May 2011
Posts: 8

View user's profile Send private message

PostPosted: Fri May 13, 2011 1:23 pm     Reply with quote

Ok. Thank you !
I will try with 16F PICs to test my code, but i will be better for my purpose to make it work on 18F. I hope I will not have to develop a software spi instead of using hardware mssp module...
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sat May 14, 2011 1:35 pm     Reply with quote

Last night I was able to duplicate the SPI problem, I think. I'm using two
18F2580 PICs. I put them on a 3M solderless breadboard. My test
program would run for a couple minutes, and then it would get a burst
of errors. So I think I'm seeing a similar problem.

I will work on it some more over the next few days. I think I will build
a better test platform than the 3M breadboard.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue May 17, 2011 2:19 pm     Reply with quote

I tested it, and found that unused pins that are left floating (ie., as inputs)
are a major cause of the problem. This is especially true on the Master
SPI PIC. Try adding the following code to your Master PIC. In this code,
I set all of your unused pins low, except Pin A3 (\SS out) and the SPI pins
(C3-C5) and the two RS232 pins (C6 and C7). See if this fixes the problem.

Code:

void main()
{
output_low(PIN_A0);
output_low(PIN_A1);
output_low(PIN_A2);
output_low(PIN_A4);
output_low(PIN_A5);

output_b(0);

output_low(PIN_C0);
output_low(PIN_C1);
output_low(PIN_C2);


This is for the master. I didn't test doing it for the slave, though it
would be a good idea to do it there as well. The Port A pins would
be slightly different for the slave.
lglenat



Joined: 08 May 2011
Posts: 8

View user's profile Send private message

PostPosted: Wed May 18, 2011 11:59 am     Reply with quote

It's working now Very Happy !
However, in my full code (in which i use spi) there are some inputs (from sensors, switchs, external interrupts etc.). Do you think that will cause the same problem, even if i use pull-down resistors on the concerned pins ?

Do you have an idea on the real nature of this problem ? What's the problem with floating pins ?
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed May 18, 2011 12:06 pm     Reply with quote

It seems to be a static electricity problem. Here's what I did:

1. With the board sitting on my desk, I noticed it gave small bursts of
errors every minute or so.

2. Just on a hunch, I tapped the master PIC with my finger. It got errors
every time I did that.

3. Next hunch, I touched a screw on the back of my PC with one hand
and tapped the PIC with my other hand. No errors.

4. Then I removed my hand from the screw and tapped again. No errors.

5. Then I moved my foot on the carpet and touched the PIC. Errors.

6. Then it occurred to me that all unused pins were floating. I set them
to low-level outputs and and errors stopped, even if I tapped the PIC.

Conclusion is that it's a static charge problem on the floating input pins.
I don't know the exact internal mechanism that's involved.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Goto page Previous  1, 2
Page 2 of 2

 
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