Close

NRF and Attiny not playing well together

A project log for Electric Longboard

Can we build a great board for under $400 in less than 3 weeks? (using a few pre-made kit parts)

dudeskidaddydudeskidaddy 07/11/2016 at 23:210 Comments

Can't go Nunchuck until the NRF and ATTINY play nice.

Our current NRF and Arduino Nano-based remote works well, but is big and clunky.

Before we can make a nice one inside a wiimote, we'll need to get the smaller and lower power ATTINY85 (or the larger ATTINY84 with more IO pins) working.

ATTINY / NRF is not working for us. We're trying everything we found online, including...

How do you know the Attiny's 8 mHz clock is working?

Run a simple blink sketch with a 1000ms delay using "Tools->Clock->8mHz" If the LED blinks every second, then the Tiny Clock is working at 8Mhz. If on the other hand, the LED blinks for 8 second and off for 8 seconds, then it is still running at 1mHz.

void loop() {

// put your main code here, to run repeatedly:

delay(1000);

digitalWrite(3,HIGH);

delay(1000);

digitalWrite(3,LOW);

}


To fix this...Burn Bootloader?

From Arduino IDE simply selecting "Tools->Clock->8mHz" tells the chip what the clock frequency is supposed to be so that things like timers still work. For example calling delay(1000) actually takes 1 second. But selecting 8mHz from the menu doesn't actually change the clock frequency! Turns out that to actually change the ATTINY clock frequency you have to use an Arduino as an ISP and select: "Tools->Burn Bootloader". This sets the ATTINY fuses to actually speed up the clock. Running the above blink program should yield 1-second blinks.

Confirmed @8Mhz...but still not working.

We're seeing a difference on the SPI Logic Analyzer between the Attiny and Arduino implementation. The numbers being passed are completely different and the SCK frequency is 4x slower with the ATTINY. The SPI protocol has the "master" control the SCK so that shouldn't be a problem...interesting though.

The following logic analyzer output (top row digital and again on the bottom row in analog) is showing a 1 mHz SCK frequency for the ATTINY and NRF combination.

The following logic analyzer output is showing a 4 mHz SCK frequency for the Arduino and NRF combination. Interesting how the clock is now too fast for the Saleae's relatively slow ADC to pick up the transitions. (the bottom row doesn't match the top).

Serial Print on ATTINY

We're not taking advantage of this...mainly because all the pins are taken up by the NRF. Not sure, but maybe we can get software Serial.Print working on the ATTINY84 (which has many more IO pins)

Discussions