Quantcast
Channel: Infineon Forums
Viewing all articles
Browse latest Browse all 9892

XMC4500: Separate SPI configuration for each slaves possible ?

$
0
0
Hello,

I used a relax kit to control a System Basis Chip (SBC) and EEPROM with SPI communication.

I changed the SPI configuration(frame length, LSB/MSB first etc.) before sending any SPI signals to the slaves.

Code:

void ACTIVATE_SBC(){

        if(SPI_MASTER_BCM.channel->PCR_SSCMode != XMC_SPI_CH_SLAVE_SELECT_0){

                XMC_SPI_CH_DisableSlaveSelect(XMC_SPI1_CH1); /**<  Select SBC Slave*/

                XMC_SPI_CH_EnableSlaveSelect(XMC_SPI1_CH1, XMC_SPI_CH_SLAVE_SELECT_0);

                XMC_SPI_CH_SetFrameLength(XMC_SPI1_CH1,SBC_FRAME);

                XMC_SPI_CH_SetBitOrderLsbFirst(XMC_SPI1_CH1);

                /* Configure the clock polarity and clock delay */
                XMC_SPI_CH_ConfigureShiftClockOutput(XMC_SPI1_CH1,
                                XMC_SPI_CH_BRG_SHIFT_CLOCK_PASSIVE_LEVEL_0_DELAY_DISABLED,
                                XMC_SPI_CH_BRG_SHIFT_CLOCK_OUTPUT_SCLK);

        }


}

Code:

void ACTIVATE_EEPROM(){

        if(SPI_MASTER_BCM.channel->PCR_SSCMode != XMC_SPI_CH_SLAVE_SELECT_1){

                XMC_SPI_CH_DisableSlaveSelect(XMC_SPI1_CH1); /**<  Select SBC Slave*/

                XMC_SPI_CH_EnableSlaveSelect(XMC_SPI1_CH1, XMC_SPI_CH_SLAVE_SELECT_1);

                XMC_SPI_CH_SetFrameLength(XMC_SPI1_CH1,EEPROM_FRAME);

                XMC_SPI_CH_SetBitOrderMsbFirst(XMC_SPI1_CH1);

                /* Configure the clock polarity and clock delay */
                XMC_SPI_CH_ConfigureShiftClockOutput(XMC_SPI1_CH1,
                                XMC_SPI_CH_BRG_SHIFT_CLOCK_PASSIVE_LEVEL_0_DELAY_ENABLED,
                                XMC_SPI_CH_BRG_SHIFT_CLOCK_OUTPUT_SCLK);
        }
}

Now I moved to XMC4500 F144K1024. I updated the software and did some interface changes to the software.

Code:

void ACTIVATE_SBC(){

        if(SPI_MASTER_BCM.channel->PCR_SSCMode != XMC_SPI_CH_SLAVE_SELECT_0){

                SPI_MASTER_DisableSlaveSelectSignal(&SPI_MASTER_BCM); /**<  Select SBC Slave*/

                SPI_MASTER_EnableSlaveSelectSignal(&SPI_MASTER_BCM, SPI_MASTER_BCM.config->slave_select_pin_config[0]->slave_select_ch);


                XMC_SPI_CH_SetFrameLength(XMC_SPI2_CH0,SBC_FRAME);

                XMC_SPI_CH_SetBitOrderLsbFirst(XMC_SPI2_CH0);

                /* Configure the clock polarity and clock delay */
                XMC_SPI_CH_ConfigureShiftClockOutput(XMC_SPI2_CH0,
                                XMC_SPI_CH_BRG_SHIFT_CLOCK_PASSIVE_LEVEL_0_DELAY_DISABLED,
                                XMC_SPI_CH_BRG_SHIFT_CLOCK_OUTPUT_SCLK);

        }


}

Code:

void ACTIVATE_EEPROM(){

        if(SPI_MASTER_BCM.channel->PCR_SSCMode != XMC_SPI_CH_SLAVE_SELECT_1){

                SPI_MASTER_DisableSlaveSelectSignal(&SPI_MASTER_BCM); /**<  Select SBC Slave*/

                SPI_MASTER_EnableSlaveSelectSignal(&SPI_MASTER_BCM, SPI_MASTER_BCM.config->slave_select_pin_config[1]->slave_select_ch);


                XMC_SPI_CH_SetFrameLength(XMC_SPI2_CH0,EEPROM_FRAME);

                XMC_SPI_CH_SetBitOrderMsbFirst(XMC_SPI2_CH0);

                /* Configure the clock polarity and clock delay */
                XMC_SPI_CH_ConfigureShiftClockOutput(XMC_SPI2_CH0,
                                XMC_SPI_CH_BRG_SHIFT_CLOCK_PASSIVE_LEVEL_0_DELAY_ENABLED,
                                XMC_SPI_CH_BRG_SHIFT_CLOCK_OUTPUT_SCLK);
        }
}

With the present implementation the chip select for EEPROM is always high. i.e, EEPROM slave is not being selected.

Please let me know if I am changing the configuration in the correct manner.

Viewing all articles
Browse latest Browse all 9892

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>