Hi all, i've an LM4f120H5QR, can I generate a 24 MHz clock? I'm trying to use AHB on PORTB, but i've nothing
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.
Hi all, i've an LM4f120H5QR, can I generate a 24 MHz clock? I'm trying to use AHB on PORTB, but i've nothing
Giuseppe Giancola1 said:I've nothing
"I've nothing," is serious/related kin to always precise, "Does not Work!" (and - provides little diagnostic value...)
AHB - properly set-up/config'ed - indeed enables faster output gpio toggling.
Some (slight) clarification of "nothing" surely assists...
hi! sorry for the previous post, here is the code, in the startup.ccs there is the function Commuta at the Timer0 Submitter A line.
the result is portB 7 LOW
#include "timer_config.h"
#include "inc/hw_types.h"
#include "driverlib/comp.h"
#include "inc/hw_gpio.h"
#include "driverlib/pin_map.h"
#include "inc/hw_ints.h"
#include "inc/hw_memmap.h"
#include "driverlib/sysctl.h"
#include "driverlib/interrupt.h"
#include "driverlib/rom_map.h"
#include "driverlib/gpio.h"
#include "driverlib/timer.h"
#include "driverlib/adc.h"
#include "driverlib/ssi.h"
#include "math.h"
#ifdef DEBUG
void__error__(char *pcFilename, unsigned long ulLine) {
}
#endif
void Commuta(void);
unsigned long ulPeriod;
int main(void) {
SysCtlClockSet(SYSCTL_SYSDIV_2_5|SYSCTL_USE_PLL|SYSCTL_XTAL_16MHZ|SYSCTL_OSC_MAIN);
PortFunctionInit();
SysCtlGPIOAHBEnable(SYSCTL_PERIPH_GPIOB);
GPIOPinTypeGPIOOutput(GPIO_PORTB_AHB_BASE, GPIO_PIN_5);
GPIOPinWrite(GPIO_PORTB_AHB_BASE, GPIO_PIN_5, 0);
SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER0);
TimerConfigure(TIMER0_BASE, TIMER_CFG_32_BIT_PER);
ulPeriod=(SysCtlClockGet()/20000000)/2;
TimerLoadSet(TIMER0_BASE, TIMER_A, ulPeriod -1);
IntEnable(INT_TIMER0A);
TimerIntEnable(TIMER0_BASE, TIMER_TIMA_TIMEOUT);
IntMasterEnable();
TimerEnable(TIMER0_BASE, TIMER_A);
while (1) {
}
}
void Commuta(void){
TimerIntClear(TIMER0_BASE, TIMER_A);
if(!GPIOPinRead(GPIO_PORTB_AHB_BASE, GPIO_PIN_5))
GPIOPinWrite(GPIO_PORTB_AHB_BASE, GPIO_PIN_5, GPIO_PIN_5);
else
GPIOPinWrite(GPIO_PORTB_AHB_BASE, GPIO_PIN_5, 0);
}
THANKS!
Thank you - my understanding is that the, "toggling speed-up" gained via the AHB bus is essentially confined to gpio operations. Thus - if the gpio operations are, "controlled" by an MCU timer - much of this benefit may be eroded. (lost)
You may confirm the correctness of AHB bus operation by implementing, "back to back" gpio function calls - first setting then clearing one or several AHB port pins. Perhaps best to measure & confirm that first - then see if that AHB speed gain is indeed, "held hostage" by some MCU peripheral...
Note: you likely should first compare/contrast such "back to back" gpio output via AHB versus APB bus.
ok, i understand...maybe I could have the pin toggle with the pwm feature enabled?
Giuseppe Giancola1 said:have the pin toggle with the pwm feature enabled
Now you've got the idea/spirit - but I'm uncertain if the required GPIOPinConfigure() & GPIOPinType() may "accept" the AHB bus. (I do not know)
Suggest you'll gain by first performing simple, "toggle" of GPIO Port/Pins w/bus @ APB. (i.e. do not start w/PWM implemented!) Note/log these results. (20 or so, "back to back" set/clear - and then loop - this code-block will persist sufficiently for your scope to capture/review.) With this APB bus as a measured baseline - switch to AHB - we note a nice, "speed-up."
Once implemented & confirmed - launch your PWM and see if that "AHB" advantage remains. Would be of interest to others (& myself) to learn of your results... Bon chance, mon ami.
ok, thanks, to set or clear a pin without the high level API, i shoud use the HWREG(....) function, right?
Here's what we used: (just showing 1st 4 fnt. calls - we repeated 20+ times to "firm" scope view...)
while (1)
{
HWREG(GPIO_PORTF_AHB_BASE + GPIO_O_DATA + (GPIO_PIN_4 << 2)) = GPIO_PIN_4;
HWREG(GPIO_PORTF_AHB_BASE + GPIO_O_DATA + (GPIO_PIN_4 << 2)) = 0;
HWREG(GPIO_PORTF_AHB_BASE + GPIO_O_DATA + (GPIO_PIN_4 << 2)) = GPIO_PIN_4;
HWREG(GPIO_PORTF_AHB_BASE + GPIO_O_DATA + (GPIO_PIN_4 << 2)) = 0;
}
Perhaps care, effort merits your award of, Verified Answer tick - this or other responses made your behalf...
Do implement the APB version of that code first - so that you establish a, "performance baseline." Improvement should be readily noted.
Thank you et bon chance, mon ami...
cb1_mobile said:have the pin toggle with the pwm feature enabledNow you've got the idea/spirit - but I'm uncertain if the required GPIOPinConfigure() & GPIOPinType() may "accept" the AHB bus. (I do not know)
[/quote]
APIs like GPIOPinConfigure or GPIOPinType can work with the AHB bus as well. You have to specify GPIO_PORTx_AHB_BASE instead of GPIO_PORTx_BASE as the base address of the port.
Regards,
Shashank
Thanks, but in this way I have a max frequency of 200 kHz on the output pin also with a divider by 2000000 on ulPeriod.
@ Shashank,
Don't believe the use of AHB Bus was missed. (quote confirms)
While the API does work - as you state - the direct register mode (I supplied) provides the higher frequency capability the poster sought...
cb1_mobile said:Here's what we used: (just showing 1st 4 fnt. calls - we repeated 20+ times to "firm" scope view...)
while (1)
{
HWREG(GPIO_PORTF_AHB_BASE + GPIO_O_DATA + (GPIO_PIN_4 << 2)) = GPIO_PIN_4;HWREG(GPIO_PORTF_AHB_BASE + GPIO_O_DATA + (GPIO_PIN_4 << 2)) = 0;