SPI issues (PIC 18F87J50)

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 8.

Moderator: Benj

Post Reply
User avatar
faveremario
Posts: 28
Joined: Sat Jun 02, 2012 6:08 pm
Has thanked: 8 times
Been thanked: 13 times

SPI issues (PIC 18F87J50)

Post by faveremario »

Hi all

Trying to communicate with MRF24J40MA I'm not getting the response I was looking for.
I would read from a register (which is accessed by value 34 on the logic analyzer) that has a POR-value not zero (28 to be precise).

So I took my spade & started digging to find out where things go wrong,
I found that, given the SPI-module settings (image 2) the data-signal was sometimes erroneous. On image 0 you can see that address 34 is being sent over the MOSI, but not always. In the middle you see that address 2 pops-up on the MOSI-line.
Taking a zoom on the error in image 1, I see the data-signal is set way to close to the active clock and even sometimes later than the active clock-signal!

Bug report: I tried to do it on FC7, but channel 2 is not working/supported for the chip :| (there are debug-leds on channel 1 & they are flashing, meaning that even selecting channel 2, SPI is still configured on channel 1 --> bug :wink: )

The story goes on... (sorry for the flood, I need to post other images).
Attachments
2 SPI Settings.PNG
(23.3 KiB) Downloaded 316 times
1 SPI Error.PNG
(37.97 KiB) Downloaded 316 times
0 SPI Error.PNG
(55.11 KiB) Downloaded 316 times

User avatar
faveremario
Posts: 28
Joined: Sat Jun 02, 2012 6:08 pm
Has thanked: 8 times
Been thanked: 13 times

Re: SPI issues (PIC 18F87J50)

Post by faveremario »

So perhaps I had poor PCB-lines, so I took a look to the MOSI with a scope (image 3...). It looks fine to me getting back to the fact that the MOSI-line is getting the wright value way to close/late in relation to the CLK in my opinion.
PS : The length of MOSI & CLK are 2mm different (on about 8cm length), but on these frequency this should not even matter.

So next step was : bit-banging. I wrote a little code (image 4...) to do the same thing as the component-macro's Sendchar & GetChar.
HalleluJah ! Not only you can see the MOSI-line coming up before the active clock (logic because of the delay in instruction execution) but the MRF responds correctly with a good reply (28). This confirms that the MRF is not getting the wright input!

So... Mr Leigh or Ben (or Microchip ?), what can be done about it?

I thank everyone in advance for the time taken by reading this.
Attachments
5 SPI bitbanging.PNG
(60.02 KiB) Downloaded 313 times
4 SPI bitbanging code.PNG
(15.59 KiB) Downloaded 313 times
3 MOSI signal scope.png
(44.34 KiB) Downloaded 313 times

User avatar
faveremario
Posts: 28
Joined: Sat Jun 02, 2012 6:08 pm
Has thanked: 8 times
Been thanked: 13 times

Re: SPI issues (PIC 18F87J50)

Post by faveremario »

Solution found !

SPI-setting / Clock phase should have been : trailing edge
(it was set on leading edge)

Can I delete my own posts ? (no I can't)

Post Reply