This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

TM4C123GXL programming question

Other Parts Discussed in Thread: EK-TM4C123GXL, TM4C123GH6PM

Hello,

I don't know if there is an FAQ for this, so please excuse me with this post.   I am a beginning programmer and I am confused with the data sheet for this board.  I found the register addresses for Port F, is there an individual address for the on board LED and one for sw2?   I looked at the lm4f1205qr.h file for some guidance) I understand that everything is bit manipulation. The user manual says that PF0 is switch 2. I want to use the switch to turn on/off an LED.  I've looked at some code snippets on here but I am not following how the coding works.  Is there a website or a book that shows how to how to do this kind of program specific to this board?  I have been following the example programs on state-machine for make the LEDs blink.  I've been able to manipulate blinking speed, order etc...   I'm hoping this step using the switch to turn on an LED will help me to use an external switch (motion sensor) to turn on an external LED. 

Sorry for the rambling!

Thanks in advance!

  • Hi Donato,

    Do you have a DK-TM4C123GXL Board where you are referring to the LED and SW2?

    There are some blinky LED examples that you can use as a reference for programming sequences, which I believe you are already using. If the switch is connected to PF0 then you have run into the old but raised a lot of times on the forum issue of a LOCK Pin.

    The Pin PF0 (if that is what is connected to SW2 as I am not sure which board you are using) will work as a NMI and you would need to write the NMI Interrupt Handler to control the LED.

    I hope the information at least gets you started to be able to send more information so that we can solve the issue

    Regards

    Amit

  • Hi Amit,

    I have the TM4C123G evaluation kit   EK-TM4C123GXL

    So I will be using interrupts to use the switch?

  • Amit Ashara said:
    connected to PF0 then you have run into the old but raised a lot of times on the forum

    And - of course - is it more productive for you/others to "endlessly" aid/abet in the correction? 

    How do we prevent unwanted (and further), "staff reductions" due to the multitudes of, "unwary" falling into this, "not especially well safe-guarded" trap?  And this - even after simple outsiders have long suggested, "improved safe-guards, made in greater number and placed w/far greater prominence."  (i.e. "somewhat" effective!) 

    You clearly are not the cause - but "simple survival" should motivate a fix - bit beyond the glacial pace - currently on such unwelcome/prolonged display...  There is so much "good" here - but allowing such a well identified "trap" to "linger" for so long - defies simple logic...

  • Hi Donato

    Yes, using the interrupts is much better than reading the Data Register or Polling the GPIO_0_RIS register.

    I checked the board user manual and it is connected to both PF0 and WAKE Pins. The second one should not be of concern. The pad is normally Pulled High so when you press the switch it will be low. Hence the NMI detection should be for a falling edge interrupt if you want to do an action on press of the switch or rising edge interrupt if you want to do an action on the release of the switch.

    Regards

    Amit

  • Can you tell me where I can find this information?  Is there a library file that has all this info?

    GPIO_PORTF_DIR_R

    GPIO_PORTF_DEN_R

    GPIO_PORTF_DATA_R       etc...

    I've only done embedded programming once before with the dragon board.

    I write  Set PortB ...as output with the corresponding bits...etc

    So I want to know the correct syntax for this board.. So how would I set PF0 as an input/output etc...

    Sorry for all the questions.

    Thanks,

    Donato

     

  • Hello Donato,

    The information is in the header files under tivaware installation directory.. The header file will be in the path inc\tm4c123gh6pm.h

    The correct syntax would be

    GPIO_PORTF_LOCK_R = GPIO_LOCK_KEY;

    GPIO_PORTF_CR_R |= 0x1; // Make the PF0 pin as changeable

    GPIO_PORTF_AFSEL_R &= ~(0x1); // Remove AFSEL Function

    GPIO_PORTF_DIR_R = 0x1; // Set PF0 as output

    GPIO_PORTF_DEN_R = 0x1; // Set Digital Enable

    GPIO_PORTF_DATA_R = 0x1; // Set Data bit 0 as logic 1

    Regards

    Amit