GioArca67 ha scritto:ma lo SHL non mi compilava ...
MI sa che ora ho capito perché, senza LL mi limitava a 31 gli spostamenti...
Moderatore: Paolino
avr-gcc -v
Using built-in specs.
Reading specs from /usr/lib/gcc/avr/5.4.0/device-specs/specs-avr2
COLLECT_GCC=/usr/bin/avr-gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/avr/5.4.0/lto-wrapper
Target: avr
Configured with: ../gcc/configure -v --enable-languages=c,c++ --prefix=/usr/lib --infodir=/usr/share/info --mandir=/usr/share/man --bindir=/usr/bin --libexecdir=/usr/lib --libdir=/usr/lib --enable-shared --with-system-zlib --enable-long-long --enable-nls --without-included-gettext --disable-libssp --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=avr CFLAGS='-g -O2 -fdebug-prefix-map=/build/gcc-avr-5.4.0+Atmel3.6.1=. -fstack-protector-strong -Wformat ' CPPFLAGS='-Wdate-time -D_FORTIFY_SOURCE=2' CXXFLAGS='-g -O2 -fdebug-prefix-map=/build/gcc-avr-5.4.0+Atmel3.6.1=. -fstack-protector-strong -Wformat ' FCFLAGS='-g -O2 -fdebug-prefix-map=/build/gcc-avr-5.4.0+Atmel3.6.1=. -fstack-protector-strong' FFLAGS='-g -O2 -fdebug-prefix-map=/build/gcc-avr-5.4.0+Atmel3.6.1=. -fstack-protector-strong' GCJFLAGS='-g -O2 -fdebug-prefix-map=/build/gcc-avr-5.4.0+Atmel3.6.1=. -fstack-protector-strong' LDFLAGS=-Wl,-z,relro OBJCFLAGS='-g -O2 -fdebug-prefix-map=/build/gcc-avr-5.4.0+Atmel3.6.1=. -fstack-protector-strong -Wformat ' OBJCXXFLAGS='-g -O2 -fdebug-prefix-map=/build/gcc-avr-5.4.0+Atmel3.6.1=. -fstack-protector-strong -Wformat '
Thread model: single
gcc version 5.4.0 (GCC)
GioArca67 ha scritto:In che tipo di dato immagazzini quanto ricevi dalla seriale?
GioArca67 ha scritto:Hai provato a reinviarlo indietro per vedere casa esattamente viene "capito" dall'AVR8?
GioArca67 ha scritto:Se invii una frequenza con scostamento di pochi Hz la tuning Word cambia?
GioArca67 ha scritto:Ma se invii in Hz (10000000) perché dividi per 180 e non per 180000000?
// M0 = 2^32/(180*10^6) = 23.8609294222222222....
// M = M0 * 2^27 = 3202559735.019.. = 0xBEE3 2EF7 (Still fits into an uint32_t).
#define MH 0xBEE3
#define ML 0x2EF7
// function deltaPhi works for frequencies up to 134 MHz
uint32_t deltaPhi(uint32_t frequencyHz)
{
uint32_t res, tmp, carry, f, fh, fl;
f = frequencyHz << 5 // Still fits into an uint32_t.
// We multiplied factor M0 by 2^27 and frequencyHz by 2^5. Overall, we multiplied by 2^32.
fh = f >> 16;
fl = f & 0xFFFF;
res = fl * MH + ((fl * ML) >> 16); // There cannot be carry in this sum; check by substituting the factors with their maximum values (0xFFFF)
tmp = res;
res += fh * ML; // No carry in this sum since 0xBEE3 + 0x2EF7 <= 0x10001, but I left the carry code in case the M constant is changed.
if (res < tmp)
{
// Carry above 32 bits in the sum
carry = 1 << 16;
}
else
{
// No carry
carry = 0;
}
res = fh * MH + carry + ((res + (1 << 15)) >> 16); // 1 << 15 is added to round to the nearest integer.
return res;
}
--with-double=64 --with-long-double=64
10000000.000 => 0x0e38e38e
10000000.040 => 0x0e38e38f
10000000.080 => 0x0e38e390
50000000.000 => 0x471c71c7
00032768.000 => 0x000bee33
00000000.042 => 0x00000001
00000000.080 => 0x00000002
9999999.990687
10000000.032596
10000000.074506
49999999.995343
32768.002711
0.041910
0.083819
gvee ha scritto:
- Codice: Seleziona tutto
--with-double=64 --with-long-double=64
Torna a Firmware e programmazione
Visitano il forum: Nessuno e 5 ospiti