View previous topic :: View next topic |
Author |
Message |
lglenat
Joined: 08 May 2011 Posts: 8
|
|
Posted: Fri May 13, 2011 1:23 pm |
|
|
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... |
|
![](templates/subSilver/images/spacer.gif) |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Sat May 14, 2011 1:35 pm |
|
|
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. |
|
![](templates/subSilver/images/spacer.gif) |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Tue May 17, 2011 2:19 pm |
|
|
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. |
|
![](templates/subSilver/images/spacer.gif) |
lglenat
Joined: 08 May 2011 Posts: 8
|
|
Posted: Wed May 18, 2011 11:59 am |
|
|
It's working now !
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 ? |
|
![](templates/subSilver/images/spacer.gif) |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Wed May 18, 2011 12:06 pm |
|
|
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. |
|
![](templates/subSilver/images/spacer.gif) |
|