Hello
I want to test the GPIOs with a simple toggle pin program. It works, but I wonder why it is so "slow". Here my code for toggeling GPIO1 Pin8:
#include "soc_AM335x.h"
#include "gpio_v2.h"
#include "hw_cm_per.h"
#include "hw_types.h"
#define CONTROL_CONF_UART_CTSN(n) (0x968 + ((n) * 0x10))
void main(void) {
HWREG(SOC_CONTROL_REGS + CONTROL_CONF_UART_CTSN(0)) = 0x00000007u; //pinmux mode7
HWREG(SOC_CM_PER_REGS + CM_PER_GPIO1_CLKCTRL) = 0x02;
/* Enabling the GPIO module. */
GPIOModuleEnable(SOC_GPIO_1_REGS);
/* Setting the GPIO pin as an output pin. */
GPIODirModeSet(SOC_GPIO_1_REGS, 8, GPIO_DIR_OUTPUT);
while(1)
{
HWREG(SOC_GPIO_1_REGS + GPIO_SETDATAOUT) = 256; //set GPIO 1.8
HWREG(SOC_GPIO_1_REGS + GPIO_CLEARDATAOUT) = 256; //clear GPIO 1.8
}
}
On my oscilloscope I measure an on-time of 200ns and an off-time of 270ns, making a period of 470ns. That runs with full optimization on L3 OCMC SRAM and Turbo Config (720MHz) set via GEL file. When I put on the debugger and look the disassembly I see the following reasonable short code for the while loop:
21 HWREG(SOC_GPIO_1_REGS + GPIO_SETDATAOUT) = 256; //set GPIO 1.8
$C$L1:
402f10d0: $C$L1+0 E59F0020 LDR R0, $C$CON4
402f10d4: E3A0CC01 MOV R12, #256
402f10d8: E580C000 STR R12, [R0]
22 HWREG(SOC_GPIO_1_REGS + GPIO_CLEARDATAOUT) = 256; //clear GPIO 1.8
402f10dc: E59F0018 LDR R0, $C$CON5
402f10e0: E3A0CC01 MOV R12, #256
402f10e4: E580C000 STR R12, [R0]
19 while(1)
402f10e8: EAFFFFF8 B $C$L1
Is this the fastest possible configuration for the GPIO ? Seems too slow to me. Is there a datasheet for (pin) timings for am3359?
Greetings, Björn