cancel
Showing results for 
Search instead for 
Did you mean: 

GPIO routines for IIC eeprom - tested on STM32F103RET6

mehmet.karakaya
Associate III
Posted on September 20, 2010 at 16:18

GPIO routines for IIC eeprom - tested on STM32F103RET6

5 REPLIES 5
Andrew Neil
Evangelist III
Posted on May 17, 2011 at 14:08

Note that software delay loops are liable to be optimised-out by a decent compiler.

And you haven't said what clock frequency/ies is/are appropriate to the particulare ''magic numbers'' that you've used...

trevor23
Associate III
Posted on May 17, 2011 at 14:08

And have a single software delay function instead of all the repeated loop delays e.g.

#define LOOPS_PER_MICRO_SECOND ??? // change as appropriate

void delay_uS(unsigned int uS)

{

    unsigned int volatile i;

    for (i = uS * LOOPS_PER_MICRO_SECOND; i; i--);

}

This way you have only one ''magic number'' to change when porting / changing speed i.e. LOOPS_PER_MICRO_SECOND.

Andrew Neil
Evangelist III
Posted on May 17, 2011 at 14:08

You're still missing the fundamental flaw with relying upon the execution timing of anything written in a High-Level Language (HLL) - see: 

http://www.8052.com/forum/read/162556

 (not 8052-specific)

mehmet.karakaya
Associate III
Posted on May 17, 2011 at 14:08

I think I adjusted the system clock to 72 Mhz

so the magic numbers dont need to be changed for slower processors

I think if it runs for 72 Mhz it runs for slower too

mehmet.karakaya
Associate III
Posted on May 17, 2011 at 14:08

ok - you are right but maybe some inline assemler delay macro can be written

instead of my HLL routines - inline assembler cannot be optimized by compiler , am I wrong ?

-----------------------------

I have another question - please look at it

I want the system tick function be called every 100 milisecond 

and that it makes one variable true - thats all I want 

but when I add the below line in main() fucntion 

my program freezes - what is worng or mising in my program ?

main(){

..............

 SysTick_Config(SystemCoreClock / 10);

..............

}

in stm32f10x_it.c

-----------------------------

void SysTick_Handler(void)

{

    TIMERJOB=1;

}