A related question is a question created from another question. When the related question is created, it will be automatically linked to the original question.
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 there,
I'm trying to toggle a GPIO pin on the TM4C1290NCPTD. The oscilloscope reading this pin reports 84ns from the falling edge to the rising edge. The MCU is running at 120 MHz, which means 8.3ns/cycle. Shouldn't the oscilloscope report 16.6ns instead?
Here is the code that initializes the MCU and toggles the pin:
//g_ui32SysClock has value 120000000 after this instruction
g_ui32SysClock = SysCtlClockFreqSet((SYSCTL_XTAL_16MHZ | SYSCTL_OSC_MAIN | SYSCTL_USE_PLL | SYSCTL_CFG_VCO_480), 120000000);
while(){
HWREG(0x40005020) = 0;
HWREG(0x40005020) = LCD_WR_PIN;
}
I also checked the PLL registers and it's set to 0x11 - which means that PSYSDIV + 1 = 4, which means 480/4 = 120MHz. The MCU seems to be set up correctly, the forums here say that TM4C129 should toggle its GPIO pins once every cycle and yet it takes a lot longer to toggle a pin. What am I doing wrong?
Many thanks,
H
Have you taken the time for code execution into account? remember that instruction still needs to be fetched, executed and corresponding peripheral access generated,
In assembly you can get faster than that by ensuring that the code is kept aligned to size of the prefetch buffer. I don't have an example to illustrate though.
Your loop is executing more than two instructions (dump the assembly if you want to check). If the lines each map to a single instruction (and you would have to verify that) then you still have the loop and possibly test instructions.
Depending on how the macros were written you could end up with multiple instructions per line. I don't remember if the M4 can do a store immediate to address and that could slow you further. And you only have 5 instruction cycles. (load, store, load, store, jump would account for it if all are single cycle instructions).