How to set nRF52832 to do parallel input and output?

Nrf52832 I/O is from P0.00~P0.31, I want to use one of the I/O to do parallel input and output, how to set? For example, with P0.02~P0.17, these 16 I/O ports make a 16-bit input parallel port.

Another experiment was done today, if Bluetooth sends data (calling ble_nus_data_send function) timer240us into an interrupt is not accurate. If only the Bluetooth connection is successful and no data is sent, 40us is accurate. This is also a problem with other timers.Could you please help me find out what the reason is?

Please help resolve these problems, thanks!

Parents
  • Hello Francis,

    I have feedback from team.

    As I said in my earlier comment that we do not support parallel input/output in HW. You need to handle this in Software. For example: to read/write the IN/OUT registers of the GPIO/P0 peripheral (https://infocenter.nordicsemi.com/topic/ps_nrf52840/gpio.html?cp=5_0_0_5_8_1_0#register.OUT). 

    you can use nrf_gpio_port_in_read() and nrf_gpio_port_out_write()

     

    uint32_tgpio_output = nrf_gpio_port_out_read(NRF_GPIO->P0);    // Read current state of GPIO outputs
    gpio_output &= 0xFFFF0000;                                      // Clear lower 16 bits of P0
    gpio_output |= 0x0000AAAA;                                      // Set lower 16 bits of P0 to 0xAAAA (0b1010101010101010)
    nrf_gpio_port_out_write(NRF_GPIO->P0, gpio_output);             // Write back changed GPIO state to port
      

    One thing you have to keep in mind, writing on OUT register will affect all GPIO configured as output, that is why in the reference code you can see these are read it back before changing the values and write back to the modified registers. 

    You also need to reconfigure the direction of the GPIOs between read and write operations, for instance using nrf_gpio_port_dir_write().

    N.B: ''gpio_output &= 0xFFFF0000; // Clear lower 16 bits of P0
    gpio_output |= 0x0000AAAA;'' these are just an example you have to set the address based on your output registers.

Reply
  • Hello Francis,

    I have feedback from team.

    As I said in my earlier comment that we do not support parallel input/output in HW. You need to handle this in Software. For example: to read/write the IN/OUT registers of the GPIO/P0 peripheral (https://infocenter.nordicsemi.com/topic/ps_nrf52840/gpio.html?cp=5_0_0_5_8_1_0#register.OUT). 

    you can use nrf_gpio_port_in_read() and nrf_gpio_port_out_write()

     

    uint32_tgpio_output = nrf_gpio_port_out_read(NRF_GPIO->P0);    // Read current state of GPIO outputs
    gpio_output &= 0xFFFF0000;                                      // Clear lower 16 bits of P0
    gpio_output |= 0x0000AAAA;                                      // Set lower 16 bits of P0 to 0xAAAA (0b1010101010101010)
    nrf_gpio_port_out_write(NRF_GPIO->P0, gpio_output);             // Write back changed GPIO state to port
      

    One thing you have to keep in mind, writing on OUT register will affect all GPIO configured as output, that is why in the reference code you can see these are read it back before changing the values and write back to the modified registers. 

    You also need to reconfigure the direction of the GPIOs between read and write operations, for instance using nrf_gpio_port_dir_write().

    N.B: ''gpio_output &= 0xFFFF0000; // Clear lower 16 bits of P0
    gpio_output |= 0x0000AAAA;'' these are just an example you have to set the address based on your output registers.

Children
No Data
Related