• AVR Freaks

Hot!SPI configuration questions

Author
GunkutA
Junior Member
  • Total Posts : 107
  • Reward points : 0
  • Joined: 2019/01/10 00:09:38
  • Location: 0
  • Status: offline
2019/04/19 06:59:55 (permalink)
0

SPI configuration questions

Hello, I have some questions related to SPIxCON registers of SPI. I use PIC18F26K83.
1) There is a SPIxTCNTH: SPI TRANSFER COUNTER MSB REGISTER. And I can set first 3 bits on it which counters the bits to be transmitted. And according to datasheet it is writable bit. According to the datasheet it counts bits that will be transmitted then why is it writable? Do I need to write it according to bits that I will send? Or is it there to inform user.
 
2) There is SPIxTWIDTH: SPI TRANSFER WIDTH REGISTER. In case of BMODE=1, it is 
Size (in bits) of each transfer counted by the transfer counter

I will be sending values such as 1.1  or 2.3 to DAC. In this case what should I set it to? Is there a standart value for this register?
 
3) I couldn't get what are FIFO registers are for according to datasheet we cannot control them by software. Isn't it like a buffer? So If I am writing to transmit register faster than transmission speed, the transmit data will be put into the FIFO. And one by one they will be transmitted. Am I correct? I do not need to anything rather than writing to the transmit buffer.
 
4) I read but could not understand the polarity bits in SPIxCON1. Is it okay if I do not touch these bits in the control register? I do not want to mess up.
 
5) How can I select slaves? There is a SSET (Slave select enable bit) in the SPIxCON2 register. I can make it 1, but then how can I select the slave?
 
Thank you for your answers. I am a newbie. Sorry for the simple and maybe non sense questions. Or I can simply show my configuration code, but I believe it would be harder to analyse.
 
post edited by GunkutA - 2019/04/19 07:02:57
#1

1 Reply Related Threads

    qhb
    Superb Member
    • Total Posts : 9982
    • Reward points : 0
    • Joined: 2016/06/05 14:55:32
    • Location: One step ahead...
    • Status: offline
    Re: SPI configuration questions 2019/04/19 22:28:51 (permalink)
    +1 (1)
    GunkutA
    1) There is a SPIxTCNTH: SPI TRANSFER COUNTER MSB REGISTER. And I can set first 3 bits on it which counters the bits to be transmitted.

    That is just the high byte. There is also a "SPIxTCNTL" register, and they are used together to form an 11 bit register that hold the count of how many transfers to do.
     

    And according to datasheet it is writable bit. According to the datasheet it counts bits that will be transmitted then why is it writable?

    Because it is YOUR JOB to write into that register how many transfers to do.
     

    Do I need to write it according to bits that I will send? Or is it there to inform user.

    The first option, as the datasheet tells you.
    i.e. it says:

    the transfer counter (SPIxTCNTH/
    SPIxTCNTL) must also be written to before transfers
    will occur, and transfers will cease when the transfer
    counter reaches ‘0’.

     

    2) There is SPIxTWIDTH: SPI TRANSFER WIDTH REGISTER. In case of BMODE=1, it is 
    Size (in bits) of each transfer counted by the transfer counter

    I will be sending values such as 1.1  or 2.3 to DAC. In this case what should I set it to? Is there a standart value for this register?

    You can't write values "1.1" or "2.3" to a DAC!
    Are you actually describing voltages? You don't write the actual voltage to the DAC. You write an integer which sets the ratio of the reference voltage to be used.
    This should be documented in the datasheet of whatever DAC you are talking about.
     
    All the rest of your questions indicate that you really are not understanding anything in the datasheet, as it is all explained.
     
     
     
    #2
    Jump to:
    © 2019 APG vNext Commercial Version 4.5