#134511 - spacy51 - Fri Jul 13, 2007 2:49 pm
Hi there!
I am currently working on an OGG Vorbis player for my NDS.
Unfortunately, there is a problem when calculating the frequency of my timer in the sound output. I #included <math.h> and used either log() or log10(), but the linker(!) throws the following error:
I guess it is related to the DS not having floating point support. Fortunately, I neither need floating point parameters nor return values of the log() function. A plain integer-only function would do for my purposes. If you know of a workaround to set the TIMER0_DATA to specific frequency without using logarithm let me know.
Here's the related source code:
I am currently working on an OGG Vorbis player for my NDS.
Unfortunately, there is a problem when calculating the frequency of my timer in the sound output. I #included <math.h> and used either log() or log10(), but the linker(!) throws the following error:
Quote: |
1>d:/Dokumente/Development/nds/ogg/source/main.c(131): undefined reference to `log' |
I guess it is related to the DS not having floating point support. Fortunately, I neither need floating point parameters nor return values of the log() function. A plain integer-only function would do for my purposes. If you know of a workaround to set the TIMER0_DATA to specific frequency without using logarithm let me know.
Here's the related source code:
Code: |
void initTimer(int freq_kHz)
{ //disable the timer before changing parameters TIMER0_CR = 0; TIMER0_DATA = TIMER_FREQ_1024( log((freq_kHz / 1000)) / log(2) ); // 1 - 1Hz, 2 - 2Hz, 3 - 4Hz TIMER0_CR = TIMER_ENABLE | TIMER_DIV_1024 | TIMER_IRQ_REQ; irqSet(IRQ_TIMER0, timerHandler); irqEnable(IRQ_TIMER0); } |