infineon4engineers Facebook

infineon@google+ Google+

infineon@linkedin linkedin

infineon4engi@twitter twitter

infineon@youtube youtube

+ Reply to Thread
Results 1 to 3 of 3

Thread: XMC4700 SPI configuration --> SCLK = 8 KHz

  1. #1
    Beginner Beginner EbbeSand is on a distinguished road
    Join Date
    May 2017
    Posts
    31
    Points
    129.375

    XMC4700 SPI configuration --> SCLK = 8 KHz

    Good Morning Forum Member,

    I want to generate a SCLK frequence of 8 kHz, by SPI I can said that this is equal tp 8 kbit/s correct?

    now I have the problem which baudrate (nummeric value) is nessessary that the XMC LIB function



    Code:
    /**
     * Structure for initializing SPI channel.
     */
    typedef struct XMC_SPI_CH_CONFIG
    {
      uint32_t baudrate;							  /**< Module baud rate for communication */
      XMC_SPI_CH_BUS_MODE_t bus_mode;                 /**< Bus mode: Master/Slave */
      XMC_SPI_CH_SLAVE_SEL_MSLS_INV_t selo_inversion; /**< Enable inversion of Slave select signal relative to the internal 
                                                           MSLS signal  */
      XMC_USIC_CH_PARITY_MODE_t parity_mode;          /**< Enable parity check for transmit and received data */
    } XMC_SPI_CH_CONFIG_t;
    That the function below, called by XMC_SPI_CH_Init is set the register that the clock is work with 8 kHz

    Code:
    XMC_SPI_CH_STATUS_t XMC_SPI_CH_SetBaudrate(XMC_USIC_CH_t *const channel, const uint32_t rate)
    {
      XMC_SPI_CH_STATUS_t status;
      
      status = XMC_SPI_CH_STATUS_ERROR;
      
      if (rate <= (XMC_SCU_CLOCK_GetPeripheralClockFrequency() >> 1U))
      {
        if (XMC_USIC_CH_SetBaudrate(channel, rate, XMC_SPI_CH_OVERSAMPLING) == XMC_USIC_CH_STATUS_OK)
        {
          status = XMC_SPI_CH_STATUS_OK;
        }
      } 
      return status;
    }

    Remarks: Frequency calculation by XMC Datasheet

    fpheriph = 144 MHz --> 1/1000 (Fractional Devider) --> f = 144 kHz ---> PDIV f*1/9 ---> f = 16 KHz --> Div by 2 f*1/2 --> fsclk = 8 KHz

    But what value I need for uint32_t baudrate to set the register that the frequency calculation above is made.

    Best regards

    Ebbe Sand

  2. #2

    Infineon Employee
    Infineon Employee
    jferreira will become famous soon enough
    Join Date
    Oct 2012
    Posts
    532
    Hi,

    Code:
    .baudrate = 8000,
    Should do it??

    Regards,
    Jesus
    The views expressed here are my personal opinions, have not been reviewed or authorized by Infineon and do not necessarily represent the views of Infineon.

  3. #3
    Beginner Beginner EbbeSand is on a distinguished road
    Join Date
    May 2017
    Posts
    31
    Points
    129.375
    Hi Jesus,

    Sometimes things can be so easy that you can believe it. But now for your question yes it works.
    Thanks for your help and a successful week.

    Best regards

    Ebbe Sand

+ Reply to Thread
Disclaimer

All content and materials on this site are provided “as is“. Infineon makes no warranties or representations with regard to this content and these materials of any kind, whether express or implied, including without limitation, warranties or representations of merchantability, fitness for a particular purpose, title and non-infringement of any third party intellectual property right. No license, whether express or implied, is granted by Infineon. Use of the information on this site may require a license from a third party, or a license from Infineon.


Infineon accepts no liability for the content and materials on this site being accurate, complete or up- to-date or for the contents of external links. Infineon distances itself expressly from the contents of the linked pages, over the structure of which Infineon has no control.


Content on this site may contain or be subject to specific guidelines or limitations on use. All postings and use of the content on this site are subject to the Usage Terms of the site; third parties using this content agree to abide by any limitations or guidelines and to comply with the Usage Terms of this site. Infineon reserves the right to make corrections, deletions, modifications, enhancements, improvements and other changes to the content and materials, its products, programs and services at any time or to move or discontinue any content, products, programs, or services without notice.