This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Setting port as output, turn on led

Hello everyone. I have an evaluation kit EKK-LM3S9B96. I try to write simply program, just turn on led. I think i do it good and i don't know where i do mistake.

#include <LM3Sxxxx.H>
int main()
{
        GPIODirModeSet(GPIO_PORTD_BASE,GPIO_PIN_7,GPIO_DIR_MODE_OUT);
        GPIOPinWrite(GPIO_PORTD_BASE,GPIO_PIN_7,0xff);
}


I set pin 7 as out and next put there 1. I would be greatfull for some help.

Parents
  • Hi. I read about GPIO settings.

    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. Can anyone explain on example what write to SysCtlClockSet if i wanted to get 6MHz when the external oscillator is 16MHz.

Reply
  • Hi. I read about GPIO settings.

    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. Can anyone explain on example what write to SysCtlClockSet if i wanted to get 6MHz when the external oscillator is 16MHz.

Children