On the LM3s8962 can PB7 be used as a standard GPIO pin?
I've gone through the steps to unlock the pin and initialized the pin to be an output:
//----------------------------------------------------- //unlock? HWREG(GPIO_PORTB_BASE + GPIO_O_LOCK) = GPIO_LOCK_KEY; HWREG(GPIO_PORTB_BASE + GPIO_O_CR) = 0x80; HWREG(GPIO_PORTB_BASE + GPIO_O_AFSEL) &= 0x7f; HWREG(GPIO_PORTB_BASE + GPIO_O_LOCK) = GPIO_LOCK_KEY; HWREG(GPIO_PORTB_BASE + GPIO_O_CR) = 0x00; HWREG(GPIO_PORTB_BASE + GPIO_O_LOCK) = 0; //----------------------------------------------------- SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB); GPIOPinTypeGPIOOutput(GPIO_PORTB_BASE, GPIO_PIN_7); GPIOPadConfigSet(GPIO_PORTB_BASE, GPIO_PIN_7, GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD_WPU);
As a test I use a simple timer ISR routine to toggle the pin:
count++; if (count > DEBUG) // 250mSec { count = 0; if (toggle) { GPIOPinWrite(DEBUG_GPIO_BASE, DEBUG_0, DEBUG_0); // pin HIGH GPIOPinWrite(GPIO_PORTB_BASE, GPIO_PIN_7, GPIO_PIN_7); // pin HIGH toggle = 0; } else { GPIOPinWrite(DEBUG_GPIO_BASE, DEBUG_0, 0); // pin LOW GPIOPinWrite(GPIO_PORTB_BASE, GPIO_PIN_7, 0); // pin LOW toggle = 1; }
As a sanity check DEBUG_O was initialized to PORT G / Pin 0 and works correctly.
Any suggestions?
-- Ben
Ben,
Are you able to step through your unlock sequence and verify that these registers are indeed changing the way you want? Also why do you write the LOCK key twice?Also if you configure the pin out of its JTAG function too quickly (at the beginning of user code), you may not be able to connect with a debugger as it will not have time to "grab" the device before this configuration takes place and will essentially be locked out. To reverse this perform a "Debug Port Unlock" in LM Flash Programmer.
Give this code a try:
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB); //make sure you enable the port before trying to write to it
HWREG(0x40005000 + 0x520) = 0x1ACCE551; //key HWREG(0x40005000 + 0x524) = 0xff; //CR HWREG(0x40005000 + 0x420) = 0x00; //alternate function HWREG(0x40005000 + 0x520) = 0; // LOCK
.
-Dave
Dave,
The double lock came from the example code in gpio_jtag.c
I tried your code with mixed results. The PB7 would toggle but not to full voltage range. The signal would swing from 3.3V to 2.9V.
I set up the port as GPIO_PIN_TYPE_STD_WPU, GPIO_PIN_TYPE_STD_WPD and GPIO_PIN_TYPE_STD with the same results.
Prefer your unlock code (with its clear derivation) to that proposed.
Your code is precisely (almost) how we unlocked a different Stellaris - which is listed (somewhere) as Dust Devil Class. This class issue adds great complication - our code used this, "GPIO_LOCK_KEY_DD," as the, "lock key."
If our code lacked the _DD - part never unlocked - suffered "always high" fate - much similar to your report.
This holds true only if yours is Dust Devil or equivalent class - this class "look-up" should be instant, identified link - instead "buried" somewhere - for some (questionable) reason... (good luck). (obstruction/road-blocks - not ideal means to boost sales... even world class firms "hiccup!")
Enough soap-box (head healing from prior banging) - sense is that you may never be "unlocking" - thus cannot drive pin as GPIO. You may wish to check/verify this theory by review of the various GPIO Registers for your MCU - both "pre & post" your attempted "unlock." I would choose a different Port B pin initially - set it up as your desired output. Then review/record key GPIO Registers: (should note AFSEL = 0, DIR = 1, ODR =0, DEN = 1) for successful GPIO Output. Once confirmed - log these same registers/values (for Port_B7) prior to "unlock." Then - execute the unlock and see if you achieve the "normal/customary" readings - presented above... Good luck...