Hi. I know that my question may seems very simple but i don't know how to solve it. I'm beginning the work with EKK-LM3S9B96 and i stuck in the easiest program. I just want to turn on some led.
#include <LM3Sxxxx.H>int main(){ while(1){SysCtlClockSet(SYSCTL_SYSDIV_2,SYSCTL_USE_OSC,SYSCTL_XTAL_16MHZ); SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA); GPIOPinTypeGPIOOutput(GPIO_PORTA_BASE,GPIO_PIN_3); GPIOPinWrite(GPIO_PORTA_BASE,GPIO_PIN_3,0xff);}}I think that the section responsible for set GPIO is correct. I just enable peripheral PORTA, set PIN3 as output and write 1. I think the problem is with SysCtlClockSet. I tried several options with this funkcion and possible set clock wrong. How to calculate arguments of SysCtlClockSet? For example i want to get 6MHz oscillator. What ulConfig should be?
You forgot to link to the story so far: http://www.keil.com/forum/19369/
Latest:
There is a 'Blinky' example for every Stellaris Evaluation Kit (EK), and the DK-LM3S9B96 - so that covers every Stellaris family!
And:
There is no "EKK-LM3S9B96" listed on the TI site - only the DK-LM3S9B96: http://focus.ti.com/docs/toolsw/folders/print/dk-lm3s9b96.html
http://focus.ti.com/docs/toolsw/folders/print/dk-lm3s9b96.html
Hi Luk,
The function SysCtlClockSet is documented in the SW-DRL-UG-####.pdf file in the "docs" directory of your main StellarisWare folder. That should address your questions about how to achieve a variety of different system clock frequencies. Other than that, exactly what is the problem you are seeing?
Christian
Hi Christian,
The problem is i can't turn on led and i think when i try several options with SysCtlClockSet i may set somethink wrong. Is possibility to go back to default settings clock. I search in my Stellaris folder but i don't found a file that You write. Maybe i'm overtired and i don't see it :(
The documents are in a folder named, appropriately enough, "docs"
For Stellarisware release 7243, the document you require is: SW-DRL-UG-7243.pdf
Doubt "speed" is your problem- do realize that you've potentially turned "all bits" of that port "high." (not just your led control pin) Might it be that the Led's cathode returns to the MCU pin - meaning that MCU pin must go "low" to light the Led? Also - add delay as shown:
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
Delay();
GPIOPinTypeGPIOOutput(GPIO_PORTA_BASE,GPIO_PIN_3);
GPIOPinWrite(GPIO_PORTA_BASE,GPIO_PIN_3, GPIO_PIN_3); // preferred manner to "set" specific port pin
GPIOPinWrite(GPIO_PORTA_BASE,GPIO_PIN_3, 0); // this is how to "reset" that same pin
More useful if your code would alternate between each of the above GPIO_PIN_3 settings. You must insert delays so that you can physically "see" these changes.
Actually, his setting of the pin will only set the single pin to high, and will work just as well as the "recommended" solution. If it didn't work, correctly, then the recommended solution wouldn't work either, as it would force the outputs of the other pins on the port to zero.
The 2nd argument to GPIOPinWrite is a mask that defines which pins on the port will be written to. So a call of the form GPIOPinWrite(<port>, <pins>, 0xff) will always set the specified pins (and only the specified pins) to a high output state. And there's a small chance that it will generate smaller/faster code with an optimizer if 0xff is a constant value that's used a lot and will tend to be hanging around in a register.
You are correct - however sense that you "missed" my key word "potentially." Precision of law school & engineering exploits such detail... Stand by my post.
BTW - how many times are you/I/Andy going to "correct" such GPIO issues?