CYBLE ProCBle -> SPI Master Slave switch while runtime

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
MaPo_2163411
Level 1
Level 1
First like given

Hello,

i need to implement a SPI Slave which has to switch into Master Mode while runtime.
I tried the SCB unconfigured mode for that. But it is not working.
SPI Slave mode only (SPI configured) is working well!

This is my SPI (SCB unconfigured mode) implementation:

slave_init.mode = SPI_SPI_SLAVE;

    slave_init.submode = SPI_SPI_MODE_MOTOROLA;

    slave_init.sclkMode = SPI_SPI_SCLK_CPHA1_CPOL1;

    slave_init.oversample = SPI_SPI_OVS_FACTOR; //ignore for slave mode

    slave_init.enableMedianFilter = 0;

    slave_init.enableLateSampling = 0;

    slave_init.enableWake = 0;

    slave_init.rxDataBits = 8;

    slave_init.txDataBits = 8;

    slave_init.bitOrder = SPI_BITS_ORDER_MSB_FIRST;

    slave_init.transferSeperation = SPI_SPI_TRANSFER_SEPARATED;

    slave_init.rxBufferSize = 32;

    slave_init.rxBuffer = NULL;

    slave_init.txBufferSize = 32;

    slave_init.txBuffer = NULL;   

    slave_init.enableInterrupt = 1;

    slave_init.rxInterruptMask = SPI_INTR_RX_FULL;

    slave_init.rxTriggerLevel = 15;

    slave_init.txInterruptMask = SPI_SPI_INTR_TX_MASK;

    slave_init.txTriggerLevel = 0;

    slave_init.enableByteMode = 1;

    slave_init.enableFreeRunSclk = 0;

    slave_init.polaritySs = SPI_SPI_SS_ACTIVE_LOW;

    SPI_SpiInit(&slave_init);

    SPI_Start();

Is there any example doing this?

Any ideas how to get it running?

Thanks a lot

Best regards

Max

0 Likes
1 Solution
lock attach
Attachments are accessible only for community members.
BragadeeshV
Moderator
Moderator
Moderator
First question asked 1000 replies posted 750 replies posted

Hi MaPo_2163411​,

Unconfigured SCB mode is best suited for your application and is used when you want to change the SCB modes in run-time.

I have created a sample project to demonstrate your application. The unconfigured SCB is first configured to SPI mode slave mode. RX_FIFO_NOT_EMPTY is used to receive the bytes.

To change to SPI master mode, a pin interrupt is used (application dependent). Upon button press, the SCB is configured to SPI master mode and transmits a byte of data every 500 ms to the slave.

Please let me know if it helps.

Regards,

Bragadeesh

Regards,
Bragadeesh

View solution in original post

0 Likes
1 Reply
lock attach
Attachments are accessible only for community members.
BragadeeshV
Moderator
Moderator
Moderator
First question asked 1000 replies posted 750 replies posted

Hi MaPo_2163411​,

Unconfigured SCB mode is best suited for your application and is used when you want to change the SCB modes in run-time.

I have created a sample project to demonstrate your application. The unconfigured SCB is first configured to SPI mode slave mode. RX_FIFO_NOT_EMPTY is used to receive the bytes.

To change to SPI master mode, a pin interrupt is used (application dependent). Upon button press, the SCB is configured to SPI master mode and transmits a byte of data every 500 ms to the slave.

Please let me know if it helps.

Regards,

Bragadeesh

Regards,
Bragadeesh
0 Likes