arduino-libs-manchester icon indicating copy to clipboard operation
arduino-libs-manchester copied to clipboard

RX not working when using ATtiny at 1MHz

Open ecomesana opened this issue 10 years ago • 1 comments

The ATTiny85 code fails to read input from a 433Mhz RF receiver when working at 1MHz. The following example compiles perfectly and runs OK wihen the ATTiny85 is working at 8MHz. However, it compiles but does not receive anything (the LED connected in pin 3 does not toggle) when working at 1MHz. Any advice to solve this problem?

#include <Manchester.h>

#define LED_PIN 3
uint8_t moo = 1;

#define TX_433_PIN 0
#define RX_433_PIN 1

#define BUFFER_SIZE 10
uint8_t buffer[BUFFER_SIZE];

void setup() {
  pinMode(LED_PIN, OUTPUT);
  digitalWrite(LED_PIN, moo);
  man.workAround1MhzTinyCore(); //add this in order for transmitter to work with 1Mhz Attiny85/84
  man.setup(TX_433_PIN, RX_433_PIN, MAN_1200);
  man.beginReceiveArray(BUFFER_SIZE, buffer);
}

void loop() {

  if (man.receiveComplete()) {
    man.stopReceive();
    moo = ++moo % 2; digitalWrite(LED_PIN, moo);
    man.beginReceiveArray(BUFFER_SIZE, buffer);
  }

}

ecomesana avatar Sep 24 '14 07:09 ecomesana

The tiny can't recive with MAN_1200 at 1MHz. Try MAN_300 or 600.

As a matter of fact, this library is very inneficient since uses arduino instrucctions inside of the recive interrupt. It is common knowledge that the digitalWrite or delay functions takes hundred of instructions to the CPU. So, at high baudrate and 1Mz, the tiny can't finish the interruput routine before the next bit arrives.

I recommend you use the tiny at 8Mhz internal if you want to use this library.

regards!

elademir avatar Aug 14 '15 05:08 elademir