view delay.c @ 24:1e2fa7396f98

Reduce prescaler to 2, the flash is capable of 25MHz reads (although the touch screen is limited to ~2.5MHz)
author Daniel O'Connor <darius@dons.net.au>
date Sat, 17 Nov 2012 12:17:58 +1030
parents 891841f5f785
children a38003b97de6
line wrap: on
line source

#include <stdint.h>
#include "stm32f10x.h"
#include "delay.h"

/* Sleep for nCount usec
 * TDS1012 on 2.5usec/div shows...
 *   30usec = 29.60usec 
 *   60usec = 59.20usec 
 *
 * XXX: not sure disable IRQ stuff is working as I see occasional (small) extra delays
 */
void
delay(uint32_t nCount) {
    __disable_irq();
    for(; nCount != 0; nCount--) {
#ifdef SYSCLK_FREQ_72MHz
	__asm__("nop");
	__asm__("nop");
	__asm__("nop");
	__asm__("nop");
	__asm__("nop");
	__asm__("nop");
	__asm__("nop");
	__asm__("nop");

	__asm__("nop");
	__asm__("nop");
	__asm__("nop");
	__asm__("nop");
	__asm__("nop");
	__asm__("nop");
	__asm__("nop");
	__asm__("nop");

	__asm__("nop");
	__asm__("nop");
	__asm__("nop");
	__asm__("nop");
	__asm__("nop");
	__asm__("nop");
	__asm__("nop");
	__asm__("nop");

	__asm__("nop");
	__asm__("nop");
	__asm__("nop");
	__asm__("nop");
	__asm__("nop");
	__asm__("nop");
	__asm__("nop");

	__asm__("nop");
	__asm__("nop");
	__asm__("nop");
	__asm__("nop");
	__asm__("nop");
	__asm__("nop");
	__asm__("nop");
	__asm__("nop");

	__asm__("nop");
	__asm__("nop");
	__asm__("nop");
	__asm__("nop");
	__asm__("nop");
	__asm__("nop");
	__asm__("nop");

	__asm__("nop");
	__asm__("nop");
	__asm__("nop");
	__asm__("nop");
	__asm__("nop");
	__asm__("nop");
	__asm__("nop");
	__asm__("nop");
#else
#error Unknown clock frequency
#endif
    }
    __enable_irq();
}