Hi,
I'm using the STM32F103ZE uC on the MCBSTM32E development board. I tried the example programs, they all compile and download and run fine, but they are NOT SIMPLE. They use a lot of Library files etc, etc, etc. I just try to make some ports go high or low.
The example GPIO program states: - Enable the clock signal for the GPIO. - Configure the Alternate Function to use a GPIO (usually standard after reset). - Configure the GPIO pins as input or output. - Set remaining parameters like speed, pull-up/down. - Enable the GPIO. - Read from or write to the GPIO.
Can someone give me a simple (and I mean REALLY SIMPLE) program to control just one single GPIO port?
My questions to activate some port: - do I need something to know about internal clock signals? - do I need some startup file?
Thanks,
Henk
www.8052.com/.../162556
A nop() only adds a delay if the compiler knows that the instruction time of the nop() is an important side effect. If the compiler doesn't, then the nop is "nothing" and can be removed.
Besides - even if you do have a nop instruction in the loop, the optimization level will change the number of machine cycles neede for the loop primitives which means that the total time will change depending on what code that is generated for the loop.
A nop() can be good when you need sub-microsecond delays. Maybe get 20ns extra delay between activating two GPIO signals (under the assumption that the compiler knows and honors the "side effect" of the nop).
Whenever you want longer delays, you should look into the timer system. Either busy-looping while waiting for a timer register to reach a certain value, or do something else while waiting for the timer to generate an interrupt.
The only time you may consider software delay loops, is if you write the delay loop in assembler. And then you better avoid trying to inline that assembler inside a C function - write the delay() function fully in assembler.