As per the datasheet of STM32F103C8T6, its GPIO pins has a hardware speed limitation of 50MHz. I need to achieve speed above 10MHz, but even with assembly codes I am getting only 7.99MHz.
It is running at the maximum recommended speed of 72MHz (8MHz Crystal + PLL).
Can anyone guide me ? Please check the following assembly language loop I am using for toggling the GPIO pins.
asm(".equ GPIOB_ODR, 0x4001080C");
asm("ldr r6, = GPIOB_ODR");
asm("loop:");
asm("mov r1, #0xFFFFFFFF");
asm("strh r1, [r6]");
asm("mov r1, #0x00000000");
asm("strh r1, [r6]");
asm("b loop");
Best Answer
You have a couple of better options for driving GPIO pins:
Timers. On this part, you have seven timers, most of which can be configured to set/reset/toggle pins on certain events (such as compare match and overflow).
DMA. Set up a DMA transfer to the GPIO bit-set/reset register and you can toggle bits at bus speed. Or you can hook it up to a timer to set bits at whatever rate you want.
Creative uses of other peripherals. USART and SPI/I2S seem like particularly likely candidates.