From ddb612029958e4c53527c25b88b7d8b5b4793a7f Mon Sep 17 00:00:00 2001 From: "David A. Mellis" Date: Sun, 12 Feb 2006 16:01:59 +0000 Subject: [PATCH] Fixed (improved, at least) millis(), changed printString to take (char *) instead of (unsigned char *) to work with string literals (e.g. printString("hello");) in C++. --- targets/arduino/wiring.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/targets/arduino/wiring.c b/targets/arduino/wiring.c index f8d6d59b4..a43ea8aff 100755 --- a/targets/arduino/wiring.c +++ b/targets/arduino/wiring.c @@ -212,7 +212,7 @@ void printNewline() printByte('\n'); } -void printString(unsigned char *s) +void printString(char *s) { while (*s) printByte(*s++); @@ -284,7 +284,9 @@ unsigned long millis() // overflows when it reaches 256. we calculate the total // number of clock cycles, then divide by the number of clock // cycles per millisecond. - return timer0GetOverflowCount() * timer0GetPrescaler() * 256L / (F_CPU / 1000L); + //return timer0GetOverflowCount() * timer0GetPrescaler() * 256L / (F_CPU / 1000L); + return (unsigned long) timer0GetOverflowCount() * timer0GetPrescaler() * 2UL / (F_CPU / 128000UL); + //return (((unsigned long) timer0GetOverflowCount()) / 62UL) * (unsigned long) timer0GetPrescaler(); } void delay(unsigned long ms)