I am working on a TI's TM4C1294XL LaunchPad with KEIL and I had a problem at the begining. I installed all the drivers for both USB and KEIL then I succesfully upload TI's blinky example to board it worked without a problem. After that I add some very basic code, in the default program it only blinks the PN0 user LED and I add some code to blink PN1 additionally but nothing has changed. PN0 LED still blinking but PN1 is not. I tried to blink other onboard LEDS PF0, PF4 but the result is same. Here is the code:

#include <stdint.h>
#include <stdbool.h>
#include "inc/hw_memmap.h"
#include "driverlib/debug.h"
#include "driverlib/gpio.h"
#include "driverlib/sysctl.h"

  * @brief  Program main function
  * @param  void    
  * @retval none
int main(void)
    volatile uint32_t ui32Loop;

        /* Enable PORTN peripheral access */

    /* Check if the peripheral access is enabled. */

    /* Enable the GPIO pin for the LEDS (PN0, PN1).  Set the direction as output, and
       enable the GPIO pin for digital function. */

        /* Turn on the LEDS. */
        GPIOPinWrite(GPIO_PORTN_BASE, GPIO_PIN_0, 0x01);        
        GPIOPinWrite(GPIO_PORTN_BASE, GPIO_PIN_1, 0x01);

        /* Delay for a bit. */       
        for(ui32Loop = 0; ui32Loop < 1200000; ui32Loop++)

        /* Turn off the LEDS. */
        GPIOPinWrite(GPIO_PORTN_BASE, GPIO_PIN_0, 0x00);
        GPIOPinWrite(GPIO_PORTN_BASE, GPIO_PIN_1, 0x00);

        /* Delay for a bit. */   
        for(ui32Loop = 0; ui32Loop < 1200000; ui32Loop++)

I have been working on ST's microcontrollers for over 2 years but I never have that kind of problem. Is it possible to problem caused by some write protection feature?


This is because of the way how driverlib GPIOPinWrite function works.

void GPIOPinWrite(uint32_t ui32Port, uint8_t ui8Pins, uint8_t ui8Val)
  • ui32Port is the base address of the GPIO port.
  • ui8Pins is the bit-packed representation of the pin(s).
  • ui8Val is the value to write to the pin(s).

The ui8Val is the value that will be written to the port pins that are selected by the ui8Pins, not to the one specific pin. Thus your code will work if you rewrite it in the following way:

// Turn on the LEDs.
// Turn off the LEDs.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.