• AVR Freaks

Hot!How to Properly Use SPI SS Output dsPIC33EV256GM102

Author
grinchy95
New Member
  • Total Posts : 8
  • Reward points : 0
  • Joined: 2019/04/02 21:15:41
  • Location: 0
  • Status: offline
2020/08/14 12:57:16 (permalink)
0

How to Properly Use SPI SS Output dsPIC33EV256GM102

Hi, I am working on a project using the SPI1 interface of the dsPIC33EV256GM102 to control an MCP4922 12-bit DAC. I had no problem setting up the SPI interface using the MPLAB X code configurator, except that the slave select pin does not seem to be work as expected. I would expect that it would output a chip selection signal, that is, normally remain high, automatically writing itself low for the duration of SPI transfers. It does not seem to be doing that. I've tried messing around with the bit registers and all I can get it to do is either 1. stay low the entire time, or 2. briefly blip low at the beginning of a transfer only to write itself high again before the transfer is finished.
 
I'm currently working around this by using a gpio pin as the chip select, but I'd rather have all of this handled by the SPI interface itself if possible, so that I can have my code keep running while the write is taking place, instead of have to wait in a while loop for the write to finish. 
 
Any idea how I can get normal chip select behavior out of the SPI1 interface?
 
Here is the code I am currently using for my SPI write: 
 
    spiOut = 0B01110000 << 8; //channel a, input buffered, gain x1, output mode active
    spiOut |= val; //0-4095
    
    LATBbits.LATB5 = 0; //manual cs
    SPI1_Exchange16bit(spiOut); //write with library function
    LATBbits.LATB5 = 1; //manual cs

 
Thanks,
Emmett
#1

3 Replies Related Threads

    Antipodean
    Super Member
    • Total Posts : 1906
    • Reward points : 0
    • Joined: 2008/12/09 10:19:08
    • Location: Didcot, United Kingdom
    • Status: online
    Re: How to Properly Use SPI SS Output dsPIC33EV256GM102 2020/08/14 13:29:42 (permalink)
    0
    I had exactly this problem with a PIC24 some years ago, and Microchip just do not provide a framing pulse like you want, and what I wanted. I ended up using external logic to produce the framing pulse, initiated by the SS pulse and then counting SPI clocks.
     

    Do not use my alias in your message body when replying, your message will disappear ...

    Alan
    #2
    ric
    Super Member
    • Total Posts : 28378
    • Reward points : 0
    • Joined: 2003/11/07 12:41:26
    • Location: Australia, Melbourne
    • Status: offline
    Re: How to Properly Use SPI SS Output dsPIC33EV256GM102 2020/08/14 14:43:11 (permalink)
    5 (1)
    I think grinchy95 ignored Alan's signature line, and left "anti-podean" unmodified in a quote of his post.
    As predicted, that caused the new message to vanish.
     

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