i took a look at the soft serial library and noticed this bit of code, which i'd guess is a timing delay. there is no similar conditional for f_cpu = 8MHz, so this may be your problem.
- Code: Select all
#if (F_CPU == 16000000)
void whackDelay(uint16_t delay) {
uint8_t tmp=0;
asm volatile("sbiw %0, 0x01 \n\t"
"ldi %1, 0xFF \n\t"
"cpi %A0, 0xFF \n\t"
"cpc %B0, %1 \n\t"
"brne .-10 \n\t"
: "+r" (delay), "+a" (tmp)
: "0" (delay)
);
}
#endif
first of all, if this code compiles at all for you your board is not defined as a lilypad to the arduino environment, so i don't understand why your serial comms to the xbee is working.
second, i am not an avr assembler programmer, mostly because i'm too dim to figure out how the inline assembly embedding works in gcc.
but i'll take a crack at interpreting the snippet above.
- Code: Select all
sbiw %0, 0x01 - subtracts 1 from delay
ldi %1, 0xFF - loads -1 to temp
cpi %A0, 0xFF - compare low order byte of delay to -1
cpc %B0, %1 - compare high order byte of dela to temp, (with carry)
brne .-10 - repeat if not equal
: "+r" (delay), "+a" (temp) - this tells us the first param is delay and the second is temp
: "0" (delay) - this tells us that delay will not survive
changing the subtrahend, (wow, never thought i'd use that word again), of the sbiw instruction to 0x02 should make this work at 8MHz but, alas, only if delay is odd. i'll have to do a little research into how the avr processor flags work before i can give you an actually useful answer.
"i want to lead a dissipate existence, play scratchy records and enjoy my decline" - iggy pop, i need more