Skip to content

Commit ddb6120

Browse files
committed
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++.
1 parent 7e0183c commit ddb6120

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

targets/arduino/wiring.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ void printNewline()
212212
printByte('\n');
213213
}
214214

215-
void printString(unsigned char *s)
215+
void printString(char *s)
216216
{
217217
while (*s)
218218
printByte(*s++);
@@ -284,7 +284,9 @@ unsigned long millis()
284284
// overflows when it reaches 256. we calculate the total
285285
// number of clock cycles, then divide by the number of clock
286286
// cycles per millisecond.
287-
return timer0GetOverflowCount() * timer0GetPrescaler() * 256L / (F_CPU / 1000L);
287+
//return timer0GetOverflowCount() * timer0GetPrescaler() * 256L / (F_CPU / 1000L);
288+
return (unsigned long) timer0GetOverflowCount() * timer0GetPrescaler() * 2UL / (F_CPU / 128000UL);
289+
//return (((unsigned long) timer0GetOverflowCount()) / 62UL) * (unsigned long) timer0GetPrescaler();
288290
}
289291

290292
void delay(unsigned long ms)

0 commit comments

Comments
 (0)