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.
Hello Dorene,
PF0 is a locked pin. The following post will help you unlock it and use the comparator output
http://e2e.ti.com/support/microcontrollers/tiva_arm/f/908/t/284566.aspx
http://e2e.ti.com/support/microcontrollers/tiva_arm/f/908/t/351475.aspx
Regards
Amit
Hi,
See, the link at my signature below "TM4C123 NMI Unlock. Also, this sticky below by Sue.
-kel
I tried to run my codes in TIVABOARD TM4C123GH6PM but seem nothing show at the output PF0. Anyone can guide me where is my problem?
Here is my code :
Hi Dorene,
dorene jong said: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) |= 0x01;HWREG(GPIO_PORTF_BASE + GPIO_O_AFSEL) |= 0x400;HWREG(GPIO_PORTF_BASE + GPIO_O_DEN) |= 0x01;HWREG(GPIO_PORTF_BASE + GPIO_O_LOCK) = 0;GPIOPinTypeGPIOOutput (GPIO_PORTF_BASE,GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3);
Do you only want to output at PF0? What do you need PF1, PF2, and PF3. Try first outputting at PF0 first without the other code.If you are not familiar how to output at GPIO pins, see GPIO example program at Tivaware Peripheral Library Users Guide.
Regarding your PF0 unlocking code. Try this below. I have not tested this code below.
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);
HWREG(GPIO_PORTF_BASE + GPIO_O_LOCK) = GPIO_LOCK_KEY;
HWREG(GPIO_PORTF_BASE + GPIO_O_CR) |= 0x01;
HWREG(GPIO_PORTF_BASE + GPIO_O_LOCK) = 0;
GPIOPinTypeGPIOOutput (GPIO_PORTF_BASE, GPIO_PIN_0);
GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_0, GPIO_PIN_0); // This will output a logic 1 to PF0
-kel
Poster stated her issue was deficient Comparator Output. Thus - forcing PF0 into gpio_output is not the answer.
Instead - PF0 must be configured as an analog comparator output. Code below details: (our usage is more general purpose {i.e. more duplicative of past LM339 comparator's operation - i.e. no internal Vref})
As helper states - that pin must be first unlocked & poster appears to have understood/complied. Yet - set-up/config of PF0 as comparator output does not agree w/our coding. (ours is earlier LX4F MCU) Below are key elements of our code - but not showing the full set-up/config of PF0. (manual review indicated there)
ComparatorConfigure(COMP_BASE, 0, (COMP_TRIG_NONE | // we feed analog signals to both comp. inputs COMP_ASRCP_PIN0 | COMP_OUTPUT_NORMAL));
GPIOPinConfigure(GPIO_PF0_C0O); // comparator Output pin
GPIOPinTypeComparator(GPIO_PORTC_BASE, GPIO_PIN_6 | GPIO_PIN_7); // comparator input pins
With the code shown (above, here) the analog comparator will drive its output (PF0) "high" when the voltage upon the Comp + pin exceeds the voltage upon the Comp - pin. We did not employ the internal reference settings as they were too coarse for our usage - and we wanted to be able to "dynamically" change the comparator's set-point via SW - on the fly.
Code the poster provides (latest version) does not detail all of the set-up/config of the comparator pins.
Hello Dorene,
The issue is in the AFSEL and missing PCTL
Amit Ashara said:The issue is in the AFSEL and missing PCTL
Let the record show that the inclusion of function: "GPIOPinConfigure()" (as earlier suggested by this reporter) nicely encapsulates the "GPIO_O_PCTL" requirement. Following is a true copy of the ending code w/in GPIOPinConfigure().
// Write the requested pin muxing value for this GPIO pin.
HWREG(ulBase + GPIO_O_PCTL) = ((HWREG(ulBase + GPIO_O_PCTL) &
~(0xf << ulShift)) |
((ulPinConfig & 0xf) << ulShift));
In our long working, analog comparator code, we set both DEN and AFSEL = 1, too.
One would think (surely would hope) that the "normal" library functions could manage such fine detail. (otherwise - direct register may return to, "rule the earth.")
Might the "real issue" here be the unexplained/unexpected absence of a "real/valid" GPIOPinTypeComparatorOutput() function? One notes that, "GPIOPinTypeComparator()" is present - and strangely - may only be applied to those comparator pins serving as Inputs. Strange that, indeed! And necessitates the "cobble" of GPIO__PCTL & friends..."
Hello cb1,
Yes the function encapsulates the PCTL and for the record, GPIOPinTypeComparatorOutput is what is needed.
Regards
Amit
cb1- said:unexplained/unexpected absence of a "real/valid" GPIOPinTypeComparatorOutput() function
Thanks & pleased to see that we're in agreement, Amit. You of course are, "blameless."
I sought - via my post - to be first to raise the flag so that future lib. revisions could add this, "strangely absent" (yet fairly complex), "Analog Comparator Output" missing piece. Trust you'll, "bang the drum" so that this moves upstream...