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

GPIO act incorrectly when building with GCC

Hi,

I connected 74CH595 shift registers to nRF52DK board. When I built and upload my code with Keil everything works just fine, but if I compliled it with GCC and upload with nrfjprog, the 74CH595 cannot act properly. I need to combine the code with ble_hid which will exceed 32K limitation so I have to use GCC. Please help to advise what can be the cause.

Note 1. I have validated simple GPIO high/low control on the 595 connected pins which works fine in both Keil and GCC compilers.

Note 2. Code snippet:

#define DOUT_LINES          24
#define STCP                ARDUINO_8_PIN
#define SHCP                ARDUINO_9_PIN
#define DS                  ARDUINO_10_PIN
#define LOW                 0
#define HIGH                1

void exp_io_out_sel(int line) {
 
  if (line > DOUT_LINES -1) return;
	
  nrf_gpio_pin_write(SHCP, LOW);
  nrf_gpio_pin_write(STCP, LOW);

  for (int i = 0; i < DOUT_LINES; i++) {
    nrf_gpio_pin_write(DS, i == line);
		nrf_gpio_pin_write(SHCP, HIGH);
		nrf_gpio_pin_write(SHCP, LOW);
  }

  nrf_gpio_pin_write(STCP, HIGH);
}

Note 3. Output Result: Keil: Compiled without warning and error, specified line will be pulled high. GCC: Compiled without warning and error, specified line was not pulled high and last line always high.

Note 4. Soft-device and image address: Both use s132 soft-device with the same flash/ram addressing.

Thanks!

Related