|
|
View previous topic :: View next topic |
Author |
Message |
Miniman
Joined: 30 Apr 2007 Posts: 44
|
Software SPI problems |
Posted: Fri Jul 13, 2007 3:15 am |
|
|
I am using the built-in SoftwareSPI lib. But it doesn't work correctly.
The only signal I see when I look on the pins with my oscilloscope is the clocksignal, the dataOut signal is just high..
The code I have written is like this:
Code: |
#use Fast_io(B)
#USE SPI(MASTER, SAMPLE_RISE, MSB_FIRST, IDLE=1, DI=PIN_B4, DO=PIN_B6, CLK=PIN_B5, BAUD=102400, STREAM=SPI)
void main()
{
set_tris_b(0x10);
while(1)
{
SPI_Xfer(SPI,0b10101010);
}
}
|
I have tried using diffrent pin like PIN_B3 but none work...
But if I do like this:
Code: |
while(1)
{
output_high(PIN_B2);
SPI_Xfer(SPI,0b10101010);
output_low(PIN_B2);
SPI_Xfer(SPI,0b10101010);
}
|
Then I get the signal on the B2 pin, but the DataOut pin is just high...
I'm going crazy over this! I can't see whats wrong.. Got any suggestions?
/Miniman |
|
|
Miniman
Joined: 30 Apr 2007 Posts: 44
|
|
Posted: Fri Jul 13, 2007 4:25 am |
|
|
I think I found the problem!
if I include BITS=8 in the #use SPI it seems to work! I thought that was default..
But anyway, it seems to work now
/Miniman |
|
|
Ttelmah Guest
|
|
Posted: Fri Jul 13, 2007 4:44 am |
|
|
What compiler version?...
Have just compiled this with 4.038, and 4.042, and it is generating output on B5, and B6.
What load is on the B6 pin?.
The big problem though, is that the generated code, clocks out 32bits, not eight, so for the first 24 clocks, no output is generated on b6. Adding 'bits=8' to the declaration, solves this...
Best Wishes |
|
|
Ttelmah Guest
|
|
Posted: Fri Jul 13, 2007 4:45 am |
|
|
I see you found it while I was typing!.
Best Wishes |
|
|
Miniman
Joined: 30 Apr 2007 Posts: 44
|
|
Posted: Fri Jul 13, 2007 5:43 am |
|
|
Yes, I did. But thank you anyway! |
|
|
|
|
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
|