Should I disable system sleep when DA14580 acting as spi slave is receiving or transmitting ?

⚠️
Hi there.. thanks for coming to the forums. Exciting news! we’re now in the process of moving to our new forum platform that will offer better functionality and is contained within the main Dialog website. All posts and accounts have been migrated. We’re now accepting traffic on the new forum only - please POST any new threads at//www.wsdof.com/support. We’ll be fixing bugs / optimising the searching and tagging over the coming days.
9 posts / 0 new
Last post
cgha
Offline
Last seen:5 months 2 weeks ago
Joined:2016-03-23 13:05
Should I disable system sleep when DA14580 acting as spi slave is receiving or transmitting ?

我想实现da14580 spi的奴隶,和use additional 2 pins for transfer flow control, 1pin for master to slave data irq(M2S_irq_pin) and 1pin for slave to master irq(S2M_sync_pin). Master or slave can start spi transfer at anytime. When Master to slave irq assert, it should wait the slave S2M_sync_pin assert to indicate the slave is ready to receive data.

1. Should I call arch_disable_sleep() when I have inited the da14580 spi as slave and waiting for the spi master to start SPI transfer, and call arch_set_extended_sleep() when the transfer has finished?

2. Does the wkupct_enable_irq works at anytime? Can the pin assigned to wakeup generate interrupt at any time(when the system is in sleep, idle ,active mode), ? Since when the spi master want to transfer data to da14580(assert M2S_irq), it does not know whether the da14580 is in active mode or sleep mode, but the slave should prepare for the spi data transfer at anytime when the spi master assert the m2s_irq_pin.

3. Should I enable the EXTERNAL_WAKEUP preprocessor since the M2S_irq_pin will wake the DA14580?

Device:
PM_Dialog
Offline
Last seen:4 hours 19 min ago
Staff
Joined:2018-02-08 11:03
Hi cgha,

Hi cgha,

Thanks for your inquiry online. To be honest, I am not completely sure what you are you trying to accomplish. As far as I understand, you want to configure the DA14580 as SPI slave and wake it up through M2S_irq_pin? Be aware that when the device is in sleep mode, all the peripherals blocks are powered down, so the chip should operate n active mode. If you use the wake-up controller in order to catch the M2S_irq, this will work at any time. However, it would be very helpful to provide me more inputs for what you are doing.

Thanks, PM_Dialog

cgha
Offline
Last seen:5 months 2 weeks ago
Joined:2016-03-23 13:05
Yes, I want to use the M2S

Yes, I want to use the M2S_irq_pin to wakeup the DA14580 when the spi master want to send data via spi(whether if the DA14580 is in sleep mode or active mode),when DA14580 is ready to receive data, it ack the external mcu with the S2M_irq_pin active, then the external mcu send data. The process is as following:

DA14580 is advertising or disconnected with no advertising or connected, app running with deep sleep enabled or ext sleep enabled:

1. SPI_MASTER(external mcu) want to send data, put the M2S_irq_pin high.

2. SPI_SLAVE(DA14580) get pin interrupt via M2S_irq_pin

3. SPI_SLAVE initialize it self as spi_slave and ack S2M_irq_pin with high.

4. SPI_MASTER check the S2M_irq_pin, detect high level on S2M_irq_pin, then send spi data to DA14580.

5. SPI_MASTER put the M2S_irq_pin low when data transfer finished.

6. SPI_SLAVE put S2M_irq_pin low.

cgha
Offline
Last seen:5 months 2 weeks ago
Joined:2016-03-23 13:05
Now I can only get the first

现在我只能获得第一销中断the first packet of data, when the spi master want to send second packet, da14580 seems can not get the pin interrupt again.

PM_Dialog
Offline
Last seen:4 hours 19 min ago
Staff
Joined:2018-02-08 11:03
Hi cgha,

Hi cgha,

Since you send the second interrupt, can you please add a breakpoint in the wake-up controller callback function in order to check if hits? For configuring a wake-up pin, please have a look at the ble_app_sleepmode example of the SDK> Are you using the same code architecture?

Thanks, PM_Dialog

cgha
Offline
Last seen:5 months 2 weeks ago
Joined:2016-03-23 13:05
No, it can not get in the

Now it can enter the callback. I should call int_enable function after the pin get high again. But sometime the spi lost some byte after I send dozens of packets. The SPI_Handler seems can not get the bytes quickly enough. The master speed is about 250K bps.

void SPI_Handler(void) { if(packetLen ==13 && spiIsInited) { //GLOBAL_INT_DISABLE(); while(packetLen) { while(0xFF&GetBits16(SPI_CTRL_REG,SPI_INT_BIT)) { while (GetBits16(SPI_CTRL_REG,SPI_TXH)==1); SetWord16(SPI_RX_TX_REG0,*p_spi_txdata++); //p_spi_txdata ++; *p_spi_rxdata++ = 0xFF&GetWord16(SPI_RX_TX_REG0); SetWord16(SPI_CLEAR_INT_REG, 0x01); if(packetLen){ packetLen --; if(packetLen == 0) { SPI_Transfer_IRQ_Off(); newPacket = 1; rcvedCnt++; } } } } //GLOBAL_INT_RESTORE(); } }

PM_Dialog
Offline
Last seen:4 hours 19 min ago
Staff
Joined:2018-02-08 11:03
Hi cgha,

Hi cgha,

To be honest, I could not understand how you would like to wake-up you device upon M2S_irq_pin interrupt detection. Did you configure the wake-up controller? Only the wake-up controller can wake-up the chip.

Thanks, PM_Dialog

cgha
Offline
Last seen:5 months 2 weeks ago
Joined:2016-03-23 13:05
Now it works, So do I need to

Now the wakeup works, So do I need to call arch_disable_sleep() when the spi is transfering? Or should I keep the ble on when spi is transfering?

PM_Dialog
Offline
Last seen:4 hours 19 min ago
Staff
Joined:2018-02-08 11:03
Hi cgha,

Hi cgha,

The arch_disable_sleep() disables all sleep modes, so the system operates in active / idle modes only. The DA14580 has 2 sleep modes available:

EXTENDED sleep mode: Only the SystemRAM 42kB & RetentionRAM remain switched on.

DEEP sleep mode: Only the RetentionRAM remains switched on. The OTP must be burnt to be able to measure the DEEP sleep current.

In both of the sleep modes, all the peripheral blocks including the SPI block and the RF block are powered off, so I would suggest to keep the device in active mode while interacting with the SPI block.

Thanks, PM_Dialog