Home arrow Support arrow Forums

Luminary Micro Forums

valgamaa

Fresh Boarder
Click here to see the profile of this user

2008/05/12 15:55

Another beginners question

Hi,
I'm new to modern microcontrollers, but the LM3S1968 evaluation board has been an excellent way of 'catching-up'. I have mastered the interupt handling and am generally making good progress, but have hit a very simple obstacle that I can't climb.

I decided to convert the blinky application from direct hardware control to using the Peripheral Driver Library. Here is the code, but the LED doesn't blink - can someone tell me what I'm missing, because I can't see it?

Code:

  //***************************************************************************** // // Blink the on-board LED. // //***************************************************************************** #include "lm3s1968.h" #include "hw_gpio.h" #include "hw_ints.h" #include "hw_memmap.h" #include "hw_types.h" #include "debug.h" #include "gpio.h" #include "interrupt.h" #include "sysctl.h" int main(void) {     volatile unsigned long ulLoop;     //    unsigned long Counter;     SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOG);      GPIODirModeSet(GPIO_PORTG_BASEGPIO_PIN_2GPIO_DIR_MODE_OUT);      while(1)          {          GPIOPinWrite(GPIO_PORTG_BASEGPIO_PIN_20xff);         for(ulLoop 0ulLoop 200000ulLoop++)             {             }         GPIOPinWrite(GPIO_PORTG_BASEGPIO_PIN_20x00);         for(ulLoop 0ulLoop 200000ulLoop++)             {             }         } }



Any comments welcome, because I'm also brushing-up on C after a 20-year absence,

Thanks in advance,

Valgamaa.

login or register to reply

cb1

Platinum Boarder
Click here to see the profile of this user

2008/05/13 09:41

Re:Another beginners question

Hi back,

You are very close - the Peripheral Driver library supplied by LMI is most helpful and I would not move from it unless you have A high, high volume Application.

Add this line - just before your "while" loop

GPIOPinTypeGPIOOutput(GPIO_PORTG_BASE, GPIO_PIN_2);

The ARM compilers are VERY literal - you have to "tell" them EVERYTHING before they behave properly. While initially annoying - you will learn that this is HOW you exploit the great power and flexibility of these chips!

Let us know how you get along...

login or register to reply

valgamaa

Fresh Boarder
Click here to see the profile of this user

2008/05/13 14:01

Re:Another beginners question

Thanks, that worked perfectly. I had seen that function and thought it did the same as GPIODirModeSet(), and thought it odd that there were two functions for the same thing.

For a new technology, design environment and language, the learning has been quite gentle, and if this is the only wrinkle I find then I will be very impressed. So far I'm very happy to have moved-on from the AVR parts...

Thanks again!

login or register to reply