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.

clock frequency testing in TM4C123GH6PZ

Other Parts Discussed in Thread: TM4C123GH6PZ

Hi...I'm new to TM4C123GH6PZ (tivaware series)..my first program is toggling the LED.and i'm checking the frequency through oscilloscope.n crystal frequency is 8Mhz.

#include <stdint.h>
#include <stdbool.h>
#include "inc/hw_memmap.h"
#include "inc/hw_types.h"
#include "driverlib/sysctl.h"
#include "driverlib/gpio.h"
//uint8_t ui8PinData=2;
int main(void)
{
SysCtlClockSet(SYSCTL_SYSDIV_1|SYSCTL_USE_OSC|SYSCTL_XTAL_8MHZ|SYSCTL_OSC_MAIN);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
GPIOPinTypeGPIOOutput(GPIO_PORTA_BASE, GPIO_PIN_2|GPIO_PIN_3|GPIO_PIN_4|GPIO_PIN_5|GPIO_PIN_6|GPIO_PIN_7);
while(1)
{
GPIOPinWrite(GPIO_PORTA_BASE, GPIO_PIN_2|GPIO_PIN_3|GPIO_PIN_4|GPIO_PIN_5|GPIO_PIN_6|GPIO_PIN_7, 0xff);
SysCtlDelay(2);
GPIOPinWrite(GPIO_PORTA_BASE, GPIO_PIN_2|GPIO_PIN_3|GPIO_PIN_4|GPIO_PIN_5|GPIO_PIN_6|GPIO_PIN_7, 0x00);
SysCtlDelay(2);
//if(ui8PinData==8) {ui8PinData=2;} else {ui8PinData=ui8PinData*2;}
//}
}
}

i have set 8Mhz as an system clock.when i have checked in ossciloscope m getting 800.1k..

  • Hello Rashmi

    The SysCtlDelay takes 3 clock cycles for one delay count. hence the SysCtlDelay(2) amounts to 6 clock cycles. On top of this the GPIOPrinWrite which does take couple of clock cycles. So in turn you have divided the clock by a value of ~10.

    Now why "~" is because you need to check in the assembly code how the code execution takes place and how many instructions are used to go loop from first function call to its next instance.

    Regards

    Amit