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.

  • Resolved

TM4C123 NMI unlock

Prodigy 90 points

Replies: 6

Views: 20979

Hello everyone, I have many questions about MCU pin muxing function. I’m now using the PF0 pin of TM4C123FH6PM, because this pin is NMI function, I want to unlock and use it as normal I/O port. The code:

#include <stdint.h>

#include <stdbool.h>

#include "inc/hw_ints.h"

#include "inc/hw_memmap.h"

#include "inc/hw_types.h"

#include "driverlib/gpio.h"

#include "driverlib/sysctl.h"

#include "driverlib/systick.h"

#include "driverlib/pin_map.h"

#include "inc/hw_gpio.h"

int

main(void)

{

      volatile unsigned long ulLoop;

    SysCtlClockSet(SYSCTL_SYSDIV_1 | SYSCTL_USE_OSC | SYSCTL_OSC_MAIN |

                             SYSCTL_XTAL_16MHZ); 

   /*

     HWREG(GPIO_PORTF_BASE + GPIO_O_LOCK) = GPIO_LOCK_KEY;  

    HWREG(GPIO_PORTF_BASE + GPIO_O_CR)  = 0x01;      

   SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);     

   GPIODirModeSet(GPIO_PORTF_BASE, 0x01, GPIO_DIR_MODE_OUT);

   GPIOPadConfigSet(GPIO_PORTF_BASE, 0x01,GPIO_STRENGTH_2MA,            

                                         GPIO_PIN_TYPE_STD);

   HWREG(GPIO_PORTF_BASE + GPIO_O_LOCK) = GPIO_LOCK_KEY;  

   HWREG(GPIO_PORTF_BASE + GPIO_O_CR)   = 0x00;

   HWREG(GPIO_PORTD_BASE + GPIO_O_LOCK) = 0;         

*/

SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);                          

GPIOPadConfigSet(GPIO_PORTF_BASE, 0x02,GPIO_STRENGTH_2MA,            

                     GPIO_PIN_TYPE_STD);                            

GPIODirModeSet(GPIO_PORTF_BASE, 0x02, GPIO_DIR_MODE_OUT);         

         while(1)

    {                  

          GPIOPinWrite(GPIO_PORTF_BASE, 0x03, 0x03);

         for(ulLoop = 0; ulLoop< 200000; ulLoop++)

                 {}

           GPIOPinWrite(GPIO_PORTF_BASE, 0x03, 0x00);

           for(ulLoop = 0; ulLoop< 200000; ulLoop++)

             {}

      }

}

My questions is:

(1)    When I shield the uclocked code between  /*and */, the PF1 can output square wave signal. But when add the /**/ code to main.c, it didn’t work out. The PF0 and PF1 didn’t have output signal, and this code affect the PF1 function.

(2)I use the library about TivaWare and MDK software,

#define GPIO_LOCK_KEY      0x4C4F434B;

I don’t know where the problem is, is this wrong to unlock the NMI function?  I thank you very much for your answers. 

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.