About the use of gpiote and dppi of nrf5340

I want to use nRF5340's GPIOTE and DPPI implementation, pull up PA_SWITCH_CTX_PIN when NRF_RADIO->EVENTS_RXREADY is triggered, and pull down PA_SWITCH_CTX_PIN when NRF_RADIO->EVENTS_TXREADY is triggered;

I wrote the following code with reference to demo \v2.0.0\zephyr\samples\boards\nrf\nrfx. When I found out that using this method can only achieve one event for one task. Please how should I modify it.

	static uint8_t tx_ppi_chaannel;
	
	nrfx_gpiote_init(99);

	nrfx_gpiote_out_config_t const out_config = {
		.action = NRF_GPIOTE_POLARITY_HITOLO,
		.init_state = 1,
		.task_pin = true,
	};

	nrfx_gpiote_out_init(PA_SWITCH_CTX_PIN, &out_config);
	nrfx_gpiote_out_task_enable(PA_SWITCH_CTX_PIN);

	nrfx_dppi_channel_alloc(&tx_ppi_chaannel);

	nrfx_gppi_channel_endpoints_setup(tx_ppi_chaannel, 
		(uint32_t)&NRF_RADIO->EVENTS_RXREADY,
		nrf_gpiote_task_address_get(NRF_GPIOTE,
			nrfx_gpiote_out_task_get(PA_SWITCH_CTX_PIN)));

	nrfx_dppi_channel_enable(tx_ppi_chaannel);

Parents
  • I changed the implementation method below, it seems that the function I want has been successfully implemented, please help me confirm.

    #define PA_SWITCH_CTX_PIN NRF_GPIO_PIN_MAP(1,9)
    
    void esb_pa_ppi_init(void)
    {
    
    
    	uint8_t tx_ppi_chaannel;
    	uint8_t rx_ppi_chaannel;
    
    	NRF_GPIOTE->CONFIG[0] = GPIOTE_CONFIG_MODE_Task << GPIOTE_CONFIG_MODE_Pos |
    					GPIOTE_CONFIG_OUTINIT_High << GPIOTE_CONFIG_OUTINIT_Pos |
    					PA_SWITCH_CTX_PIN << GPIOTE_CONFIG_PSEL_Pos;
    
    	nrfx_dppi_channel_alloc(&tx_ppi_chaannel);
    	printk("tx ppi ch %d\r\n", tx_ppi_chaannel);
    	NRF_GPIOTE->SUBSCRIBE_CLR[0] = DPPIC_SUBSCRIBE_CHG_EN_EN_Msk | tx_ppi_chaannel;
    	NRF_RADIO->PUBLISH_RXREADY = DPPIC_SUBSCRIBE_CHG_EN_EN_Msk | tx_ppi_chaannel;
    	nrfx_dppi_channel_enable(tx_ppi_chaannel);
    
    	nrfx_dppi_channel_alloc(&rx_ppi_chaannel);
    	printk("rx ppi ch %d\r\n", rx_ppi_chaannel);
    	NRF_GPIOTE->SUBSCRIBE_SET[0] = DPPIC_SUBSCRIBE_CHG_EN_EN_Msk | rx_ppi_chaannel;
    	NRF_RADIO->PUBLISH_TXREADY = DPPIC_SUBSCRIBE_CHG_EN_EN_Msk | rx_ppi_chaannel;
    
    	nrfx_dppi_channel_enable(rx_ppi_chaannel);
    
    
    }

Reply
  • I changed the implementation method below, it seems that the function I want has been successfully implemented, please help me confirm.

    #define PA_SWITCH_CTX_PIN NRF_GPIO_PIN_MAP(1,9)
    
    void esb_pa_ppi_init(void)
    {
    
    
    	uint8_t tx_ppi_chaannel;
    	uint8_t rx_ppi_chaannel;
    
    	NRF_GPIOTE->CONFIG[0] = GPIOTE_CONFIG_MODE_Task << GPIOTE_CONFIG_MODE_Pos |
    					GPIOTE_CONFIG_OUTINIT_High << GPIOTE_CONFIG_OUTINIT_Pos |
    					PA_SWITCH_CTX_PIN << GPIOTE_CONFIG_PSEL_Pos;
    
    	nrfx_dppi_channel_alloc(&tx_ppi_chaannel);
    	printk("tx ppi ch %d\r\n", tx_ppi_chaannel);
    	NRF_GPIOTE->SUBSCRIBE_CLR[0] = DPPIC_SUBSCRIBE_CHG_EN_EN_Msk | tx_ppi_chaannel;
    	NRF_RADIO->PUBLISH_RXREADY = DPPIC_SUBSCRIBE_CHG_EN_EN_Msk | tx_ppi_chaannel;
    	nrfx_dppi_channel_enable(tx_ppi_chaannel);
    
    	nrfx_dppi_channel_alloc(&rx_ppi_chaannel);
    	printk("rx ppi ch %d\r\n", rx_ppi_chaannel);
    	NRF_GPIOTE->SUBSCRIBE_SET[0] = DPPIC_SUBSCRIBE_CHG_EN_EN_Msk | rx_ppi_chaannel;
    	NRF_RADIO->PUBLISH_TXREADY = DPPIC_SUBSCRIBE_CHG_EN_EN_Msk | rx_ppi_chaannel;
    
    	nrfx_dppi_channel_enable(rx_ppi_chaannel);
    
    
    }

Children
Related