Hello i want to write a byte to P0.24 ~~P0.31 without affecting other pins on Port P0 What i shuld i do ? Guide me thank you
Hello i want to write a byte to P0.24 ~~P0.31 without affecting other pins on Port P0 What i shuld i do ? Guide me thank you
Hi
In that case you should use a bitmask to mask out the bits that you want to change.
Something like this:
#define MY_PINS_POS 24 #define MY_PINS_MASK 0xFF000000 #define OTHER_PINS_MASK (~MY_PINS_MASK) // Change P0.24-P0.31 only uint8_t my_data = 12; NRF_P0->OUT = (NRF_P0->OUT & OTHER_PINS_MASK) | ((uint32_t)my_data << MY_PINS_POS);
Best regards
Torbjørn
static void SPI_WriteDat8Bit( uint8_t DByte )
{
NRF_GPIO_Type *p_reg=NRF_P0;
uint32_t value=0;
value = nrf_gpio_port_out_read(p_reg);
value &= 0x00FFFFFF;
value |= (DByte<<24);
nrf_gpio_port_out_write(p_reg, value);
}
Can I do this? The value is read from port 0, and then p24 to 31 is cleared and assigned.
ovrebekk ,thanks your reply
Hi
You welcome
The code below looks correct.
Best regards
Torbjørn
Hi
You welcome
The code below looks correct.
Best regards
Torbjørn