This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

I2C interrupt while softdevice enabled

Hello,

i'm sorry for asking again, but i read nearly all threads about I2C and didn't get any answer yet.

I want to use the interrupt to control the I2C sequences and safe energy (instead of using while loops)

I replaced the NRF_TWI1->INTENSET.... with sd_app function below... If i start a transmition it never goes into the handler or generates an event. can anybody tell me why?

Is the NVIC_ENABLEIRQ right to use? in the end i have the usual handler.

	void init_TWI1()
{
	//I2C Init start
uint32_t err_code;
NVIC_EnableIRQ(SPI1_TWI1_IRQn);
NRF_GPIO->PIN_CNF[1] = 0x60C;
NRF_TWI1->PSELSCL = 0;	//P0 als SCL
NRF_TWI1->PSELSDA = 1;	//P1 als SDA      
NRF_TWI1->FREQUENCY = 0x06680000;	//Frequenz = 400kHz

err_code = sd_ppi_channel_assign(0,
																		&(NRF_TWI1->EVENTS_BB),
                                 &(NRF_TWI1->EVENTS_TXDSENT));

	
	
		
//I2C init end
}



	void SPI1_TWI1_IRQHandler(void) 
{
	if(NRF_TWI1->EVENTS_RXDREADY != 0)
	{
		NRF_TWI1->EVENTS_RXDREADY = 0;
	}
		if(NRF_TWI1->EVENTS_TXDSENT != 0)
	{
		NRF_TWI1->EVENTS_TXDSENT = 0;
	}
		if(NRF_TWI1->EVENTS_BB != 0)
	{
		sd_app_evt_wait();
		NRF_TWI1->EVENTS_BB = 0;
	}

}
Parents
  • Try to use sd_nvic_enableIRQ(SPI1_TWI1_IRQn); instead of "non-sd" NVIC_EnableIRQ(). By default all the interrupt priorities are set to 0 (highest priority) which is reserved exclusively for SoftDevice. Thus, the SoftDevice may become unstable. Alternatively, you can try to set the priority of SPI1_TWI1_IRQn interrupt to 1 - 3.

    I am also not sure if you can put the sd_app_evt_wait directly into interrupts. It should be in the main cycle. When the handler ends it job, it jumps back to the main cycle and goes to sd_app_evt_wait.

Reply
  • Try to use sd_nvic_enableIRQ(SPI1_TWI1_IRQn); instead of "non-sd" NVIC_EnableIRQ(). By default all the interrupt priorities are set to 0 (highest priority) which is reserved exclusively for SoftDevice. Thus, the SoftDevice may become unstable. Alternatively, you can try to set the priority of SPI1_TWI1_IRQn interrupt to 1 - 3.

    I am also not sure if you can put the sd_app_evt_wait directly into interrupts. It should be in the main cycle. When the handler ends it job, it jumps back to the main cycle and goes to sd_app_evt_wait.

Children
No Data
Related