• AVR Freaks

Hot!Master slave PICs SPI errors

Page: < 12 Showing page 2 of 2
Author
ric
Super Member
  • Total Posts : 30266
  • Reward points : 0
  • Joined: 2003/11/07 12:41:26
  • Location: Australia, Melbourne
  • Status: online
Re: Master slave PICs SPI errors 2021/01/28 02:20:22 (permalink)
+2 (2)
Camerart
...
I'm guessing that asserted means in the programs, but only 1x CS is addressed in the programs, so I left it connected, I misunderstood.

Re-reading this, maybe you mean you do have multiple SS pins.
You have not revealed which PIC pins they are connected to, but this program is setting all unused pins low.
Assuming they are all active low, that means they are all asserted at the same time.

I also post at: PicForum
Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
NEW USERS: Posting images, links and code - workaround for restrictions.
To get a useful answer, always state which PIC you are using!
#21
Camerart
Starting Member
  • Total Posts : 69
  • Reward points : 0
  • Joined: 2013/04/12 02:19:40
  • Location: 0
  • Status: offline
Re: Master slave PICs SPI errors 2021/01/28 03:04:38 (permalink)
0
Hi R,
Lots of good stuff there, thanks.
 
I'll change the PORT to LAT.  I think LAT means latched, wich to me seem more positive, although I'm not sure.
 
Normally the MASTER 4620 addresses 3x peripherals, and the 4431 is an addition, so I'm only trying to get that to work on it's own first.  I didn't know that, the CS count has to equal the peripheral count, I'll be more careful.
 
I normally use CS, but as the 4431 is addressed via an SS input PIN, I kind of use SS on this one only, to remind me.  Each peripheral, has it's own CS, so e,g, this one would be 4431_CS and be connected to it's SS PIN.
 
The person that wrote those programs, has been very helpful, so I can't tell him he doesn't know what he's doing really :)
 
 
I have 2x PCBs almost the same.  I've been testing all morning, and the same result on one PCB, i,e, with the altemeter connected, than rubbisg signal, and removed good.
The second board had an altimeter, and a logic analyser and only when they were remomved did it work, and the oscilloscope needs to be set to x10 to work, but both seem to be reliably working with those programs, before me changing them.
 
"You have not revealed which PIC pins they are connected to, but this program is setting all unused pins low.
Assuming they are all active low, that means they are all asserted at the same time."
Looking through the programs:  I can see there's some confusion with the CS-SS somewhere, but it will take me a while to figure it out. 
 
Would you talk me through the programs, so I can safely change them please?
C
post edited by Camerart - 2021/01/28 08:17:34
#22
ric
Super Member
  • Total Posts : 30266
  • Reward points : 0
  • Joined: 2003/11/07 12:41:26
  • Location: Australia, Melbourne
  • Status: online
Re: Master slave PICs SPI errors 2021/01/28 03:16:02 (permalink)
+1 (1)
Your 4431 program was empty.
You still have not revealed whic pins on your 4620 are used for the SS signals.
As I said, that code initialises all pins to zero, so it is activating ALL your slave devices at the same time.
 
I'm not familiar with that dialect of Basic. What is the syntax for passing a value to a subroutine?
 

I also post at: PicForum
Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
NEW USERS: Posting images, links and code - workaround for restrictions.
To get a useful answer, always state which PIC you are using!
#23
Camerart
Starting Member
  • Total Posts : 69
  • Reward points : 0
  • Joined: 2013/04/12 02:19:40
  • Location: 0
  • Status: offline
Re: Master slave PICs SPI errors 2021/01/28 03:34:36 (permalink)
0
ric
Your 4431 program was empty.
You still have not revealed whic pins on your 4620 are used for the SS signals.
As I said, that code initialises all pins to zero, so it is activating ALL your slave devices at the same time.
 
I'm not familiar with that dialect of Basic. What is the syntax for passing a value to a subroutine?
 


Hi R,
If I didn't clarify which PINs in my last post, please remind me.
I've also updated the 4431 program, which hopefully now has some content.
 
I'll look into the ALL activated note.
 
I rely on PIC BASIC in the Oshonsoft simulator, I've tried moving to C++, but failed, sorry.  I'm slightly dyslexic.
 
C.
#24
ric
Super Member
  • Total Posts : 30266
  • Reward points : 0
  • Joined: 2003/11/07 12:41:26
  • Location: Australia, Melbourne
  • Status: online
Re: Master slave PICs SPI errors 2021/01/28 04:49:32 (permalink)
+1 (1)
Camerart
...
If I didn't clarify which PINs in my last post, please remind me.

You said you already have three slave peripherals, and the 4431 is an extra one (making four)
You also said that each slave has its own SS pin.
That means you have four SS pins that each muist connect to a unique pin on your Master PIC.
You can NOT connect them all to the same pin on the Master.
It is the SS pin that controls WHICH slave device is being addressed.
 
I rely on PIC BASIC in the Oshonsoft simulator, I've tried moving to C++, but failed, sorry.  I'm slightly dyslexic.

There is no C++ for 8 bit PICs, only "C", which is not the same as C++, it is simpler.

I also post at: PicForum
Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
NEW USERS: Posting images, links and code - workaround for restrictions.
To get a useful answer, always state which PIC you are using!
#25
Camerart
Starting Member
  • Total Posts : 69
  • Reward points : 0
  • Joined: 2013/04/12 02:19:40
  • Location: 0
  • Status: offline
Re: Master slave PICs SPI errors 2021/01/28 06:35:57 (permalink)
0
ric
Camerart
...
If I didn't clarify which PINs in my last post, please remind me.

You said you already have three slave peripherals, and the 4431 is an extra one (making four)
You also said that each slave has its own SS pin.
That means you have four SS pins that each muist connect to a unique pin on your Master PIC.
You can NOT connect them all to the same pin on the Master.
It is the SS pin that controls WHICH slave device is being addressed.
 
I rely on PIC BASIC in the Oshonsoft simulator, I've tried moving to C++, but failed, sorry.  I'm slightly dyslexic.

There is no C++ for 8 bit PICs, only "C", which is not the same as C++, it is simpler.


Hi R,
For testing MASTER4620 /SLAVE4431 as you can see in the prgrams, only one CS is used between these two PICs.  I didn't realise that the Altimeter peripheral was still plugged onto the PCB, and that it mattered. It is now OFF and the system is working ok.
Normally all of the peripherals have their own decicated PIN to PIN connection/track.  Once this extra 4431 SLAVE peripheral is wotking, then it will be added to the list of CSs.
 
C++/C no problem, as I'm stuck with only OSH BASIC.
 
I have now moved to another computer, and the first test showed errors but I noticed I had left a special connector, where I can connect to 'say' an oscilloscope onto the PINs, once removed it now shows it working, but as you can see the A is missing from the first RECEIVE?  I still have to figure out your line order suggestion, then I'll correct the programs.
Thanks, C.
post edited by Camerart - 2021/01/29 03:49:37

Attached Image(s)

#26
Camerart
Starting Member
  • Total Posts : 69
  • Reward points : 0
  • Joined: 2013/04/12 02:19:40
  • Location: 0
  • Status: offline
Re: Master slave PICs SPI errors 2021/01/28 08:19:23 (permalink)
0
Hi R,
In #?? My statement of the 4431_cs was wrong.
Here is a correction: 4620 to 4431 CS is 4620PORTD.2 to 4431PORTC.6
C
post edited by Camerart - 2021/01/28 08:22:38
#27
Camerart
Starting Member
  • Total Posts : 69
  • Reward points : 0
  • Joined: 2013/04/12 02:19:40
  • Location: 0
  • Status: offline
Re: Master slave PICs SPI errors 2021/01/30 03:00:01 (permalink)
0
Hi R,
After a lot of tests, the results are still intermittent.
As mentioned the 18F4431 PIC has a weak MISO, I have had this problem previously with another peripheral, where I added a booster/buffer to get it working.
 
ric
Whoever wrote this program does not understand SPI.
The SS signal is not being asserted until AFTER the data has been written to SSPBUF. That is wrong.
 

I notice a repeated line 's2m = SSPBUF '  Is this what you mean?
 
My latest thought is: that I add a buffer into the MISO line to boost the signal, as it is being intermittently squashed, see images.  The one named 'No resistor', is the READing with the 4620 MISO disconnected, the one marked 'With resistor' is with the 4620 connected through a 1K resistor, and it can be seen that the voltage is being pulled down, also corrupted.
 
I now think it is best to have 4620 as MASTER and 4431 as always SLAVE, and from a previous suggestion, have the 4620 READ all peripherals, and pass some DATA to the SLAVE for processing.  Does this sound good?
 
Top line MISO bottom line MOSI
C.
 
 
post edited by Camerart - 2021/01/30 03:02:51

Attached Image(s)

#28
ric
Super Member
  • Total Posts : 30266
  • Reward points : 0
  • Joined: 2003/11/07 12:41:26
  • Location: Australia, Melbourne
  • Status: online
Re: Master slave PICs SPI errors 2021/01/30 03:37:42 (permalink)
+1 (1)
The "intermittently squished" means something else is driving that pin.
Just adding stronger buffers is NOT the answer.
Disconnecting the other device, or making sure its CS pin is not activated, is the correct fix.
 

I also post at: PicForum
Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
NEW USERS: Posting images, links and code - workaround for restrictions.
To get a useful answer, always state which PIC you are using!
#29
Page: < 12 Showing page 2 of 2
Jump to:
© 2021 APG vNext Commercial Version 4.5