2010-09-20 07:18 AM
GPIO routines for IIC eeprom - tested on STM32F103RET6
2011-05-17 05:08 AM
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...2011-05-17 05:08 AM
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.2011-05-17 05:08 AM
You're still missing the fundamental flaw with relying upon the execution timing of anything written in a High-Level Language (HLL) - see:
(not 8052-specific)2011-05-17 05:08 AM
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 too2011-05-17 05:08 AM
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; }