• AVR Freaks

Hot!PIC18F46K80 MSSP

Author
mumble_myopia1
New Member
  • Total Posts : 7
  • Reward points : 0
  • Joined: 2019/12/30 05:04:22
  • Location: 0
  • Status: offline
2020/01/03 08:45:01 (permalink)
0

PIC18F46K80 MSSP

We are controlling a device over SPI through the MSSP and now find that for reasons best known to its builders they return some data as non multiples of 8 bits. What is the best way of achieving this? I can see 3 possible ways
1) rewire our HW so we connect the SPI onto some GPIO and bit bash it
2) my preference is that the MSSP can cope with the incomplete bytes and somehow read the bits (pun not intended) we want and we ignore anything else - my suspicion is that won't work
3) somehow get access to the SPI pins and bypass the MSSP for the times we are interested in reading data back - again I suspect this isn't possible
 
Any help or info would be appreciated
 
Peter
 
#1

12 Replies Related Threads

    mbrowning
    USNA79
    • Total Posts : 1628
    • Reward points : 0
    • Joined: 2005/03/16 14:32:56
    • Location: Melbourne, FL
    • Status: offline
    Re: PIC18F46K80 MSSP 2020/01/06 12:29:07 (permalink)
    +3 (3)
    Most such devices I’ve used have no problem with additional clocks after the last data bit. Just round up to the nearest byte and ignore or zero out any non-implemented bits in that last byte.
    #2
    mumble_myopia1
    New Member
    • Total Posts : 7
    • Reward points : 0
    • Joined: 2019/12/30 05:04:22
    • Location: 0
    • Status: offline
    Re: PIC18F46K80 MSSP 2020/01/07 01:54:40 (permalink)
    0
    I'm more concerned at the lack of clocks - first 8 bits will be fine but the trailing odd "non-bits" won't have any clocks. EG if there are 9 bits returned then the last bit may get left dangling
    #3
    1and0
    Access is Denied
    • Total Posts : 10346
    • Reward points : 0
    • Joined: 2007/05/06 12:03:20
    • Location: Harry's Gray Matter
    • Status: offline
    Re: PIC18F46K80 MSSP 2020/01/07 02:27:15 (permalink)
    0
    Isn't your PIC the master?
     
    #4
    mumble_myopia1
    New Member
    • Total Posts : 7
    • Reward points : 0
    • Joined: 2019/12/30 05:04:22
    • Location: 0
    • Status: offline
    Re: PIC18F46K80 MSSP 2020/01/07 02:31:50 (permalink)
    0
    It is but I have no access to the clock line otherwise I could pulse it - the MSSP sits twixt I and that
    #5
    ric
    Super Member
    • Total Posts : 25592
    • Reward points : 0
    • Joined: 2003/11/07 12:41:26
    • Location: Australia, Melbourne
    • Status: online
    Re: PIC18F46K80 MSSP 2020/01/07 02:51:06 (permalink)
    +2 (2)
    You're not understanding the suggestion.
    Get your Master to transfer a whole extra byte, which will cause a few more clocks to be output than your device requires.
    mbrowning's point is that the device won't mind the extra clocks.

    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!
    #6
    mumble_myopia1
    New Member
    • Total Posts : 7
    • Reward points : 0
    • Joined: 2019/12/30 05:04:22
    • Location: 0
    • Status: offline
    Re: PIC18F46K80 MSSP 2020/01/07 02:58:09 (permalink)
    0
    Ah, that sorta makes sense - good point. I now have hope. Will report back
     
    Thanks very much all!
    #7
    1and0
    Access is Denied
    • Total Posts : 10346
    • Reward points : 0
    • Joined: 2007/05/06 12:03:20
    • Location: Harry's Gray Matter
    • Status: offline
    Re: PIC18F46K80 MSSP 2020/01/07 02:58:45 (permalink)
    0
     
    Exactly, e.g. for 9 bits just do 16 bits (2 bytes) transfers.
    #8
    mumble_myopia1
    New Member
    • Total Posts : 7
    • Reward points : 0
    • Joined: 2019/12/30 05:04:22
    • Location: 0
    • Status: offline
    Re: PIC18F46K80 MSSP 2020/01/20 06:10:52 (permalink)
    0
    hmm - wasn't the golden key I hoped for. The device we are talking to isn't a true SPI device (although it reads via SPI ok). To read data back we are going to have to bit blat it (so will do both). Can the pins used by the MSSP be reconfigured as GPIO so we can or do we have to re-route them to other pins?
    #9
    Mysil
    Super Member
    • Total Posts : 3642
    • Reward points : 0
    • Joined: 2012/07/01 04:19:50
    • Location: Norway
    • Status: offline
    Re: PIC18F46K80 MSSP 2020/01/20 07:55:38 (permalink)
    +1 (1)
    Hi,
    Just disable the MSSP,
        SSPCONbits.SSPEN = 0;
    then the pins are accessible as GPIO.
     
    Also, you may preset the TRISx  bits and  LATx  bits with the values you want for SPI signal lines to have when SPI peripheral is disabled.
    You may read the logic level of SPI signal lines by reading PORTx  register at any time.
    SPI peripheral have priority over LATx register when the MSSP peripheral is Enabled.
     
        Mysil
    post edited by Mysil - 2020/01/20 08:04:50
    #10
    mumble_myopia1
    New Member
    • Total Posts : 7
    • Reward points : 0
    • Joined: 2019/12/30 05:04:22
    • Location: 0
    • Status: offline
    Re: PIC18F46K80 MSSP 2020/01/20 07:57:07 (permalink)
    0
    Oooh that is good news - I was sure I read that if you disable it, those lines are tied high in the datasheet
     
    #11
    mumble_myopia1
    New Member
    • Total Posts : 7
    • Reward points : 0
    • Joined: 2019/12/30 05:04:22
    • Location: 0
    • Status: offline
    Re: PIC18F46K80 MSSP 2020/01/21 11:25:27 (permalink)
    0
    Many thanks all - wasn't supposed to be working today but couldn't resist trying something. Disabled the MSSP and wiggled the clock in a pattern which was picked up on oscilloscope so concept proved!
    #12
    ric
    Super Member
    • Total Posts : 25592
    • Reward points : 0
    • Joined: 2003/11/07 12:41:26
    • Location: Australia, Melbourne
    • Status: online
    Re: PIC18F46K80 MSSP 2020/01/21 12:14:00 (permalink)
    0
    mumble_myopia1
    Oooh that is good news - I was sure I read that if you disable it, those lines are tied high in the datasheet

    I have not heard of any PIC that does that.
     

    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!
    #13
    Jump to:
    © 2020 APG vNext Commercial Version 4.5