This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Controlling port pins

I am trying to debug a SPI application using Keil and the Eval board, but am having problems with control of the port pins. I am using pin 23 as the CS pin. it configures correctly as an output, but the functions NRF_GPIO->OUTSET = 23; and NRF_GPIO->OUTCLR = 23; have no effect on GPIO pin 23. however these instructions cause GPIO pins 0, 1, 2 and 4 to be set/reset. These two functions are declared in nrf_gpio.h :-

static __INLINE void nrf_gpio_pin_set(uint32_t pin_number)

{

NRF_GPIO->OUTSET = (1UL << pin_number);

}

However, if I call the function nrf_gpio_pin_set(23); followed by nrf_gpio_pin_clear(23); in a loop the pin toggles as it should.

There also appears to be no activity on the other SPI pins - but one problem at a time !

Parents
  • Yes, that is correct. If you do a NRF_GPIO->OUTSET = 23; you are setting the output states for the entire port, not GPIO pin 23. That is why the nrf_gpio_pin_set shifts a 1 bit by the pin number you pass in to set the pin as an output. I'd suggest reading the GPIO section of the reference manual (Section 14 in revision 3.0). Note that setting a OUTSET bit to a zero has no effect which is why that assignment doesn't need to be an |=

Reply
  • Yes, that is correct. If you do a NRF_GPIO->OUTSET = 23; you are setting the output states for the entire port, not GPIO pin 23. That is why the nrf_gpio_pin_set shifts a 1 bit by the pin number you pass in to set the pin as an output. I'd suggest reading the GPIO section of the reference manual (Section 14 in revision 3.0). Note that setting a OUTSET bit to a zero has no effect which is why that assignment doesn't need to be an |=

Children
Related