I am trying to program the attiny84, and set a pin to have its internal pull-up resistor enabled. According to the datasheet(bottom of page 71), I would need to do something like:PUEB |= 1<<PUEB3
to enable PORTB3’s internal pull-up resistor. Unfortunately, using the arduino ide 1.8.5, and the attiny board library 1.0.2, PUEB was not declared in the scope even when avr/io.h is included.
I am not sure how to get around this, or what I need to include so that PUEB is defined. Has anyone else encountered this? Where should I file a bug report?
Edit: I have notice that the guidelines suggest posting the code for the sketch I am using so that I do not waste others’ time. I am using this TinyWire library.
// SCL on physical pin 9 (PA4)
// SDA on physical pin 7 (PA6)
// sensor on physical pin 3 (PB1)
#include <avr/interrupt.h>
#include <avr/io.h>
#include <avr/pgmspace.h>
#include "TinyWire.h"
// this is for physical pin 3, PB1
#define SENSOR_PIN PB1
#define mAddr 0x0A
#define STRING_LENGTH 5
volatile int blipsSeen = 0, i2cIndex = 0;
long lastTime = 0;
float flow = 0;
volatile char flowString[STRING_LENGTH];
ISR(INT0_vect) {
blipsSeen++;
}
// This should be called STRING_LENGTH number of times in quick succession.
void i2cISR() {
TinyWire.send(flowString[i2cIndex++]);
if(i2cIndex == STRING_LENGTH)
i2cIndex = 0;
}
void setupFlowSensor() {
blipsSeen = 0;
DDRB &= ~(1<<SENSOR_PIN); // enables SENSOR_PIN to be an input
PUEB |= 1<<SENSOR_PIN; // enables a 10kOhm pullup resistor on SENSOR_PIN
PCMSK1 |= 1<<SENSOR_PIN; // enables SENSOR_PIN to be a pin listening for interrupts
GIMSK |= 1<<INT0; // enables INT0 interrupt
MCUCR |= 1<<ISC01 | 1<<ISC00; // enables only rising edge to trigger INT0
SREG |= 1<<7; // enables interrupts
}
void estimateFlow() {
// if 1000ms have passed or the millis counter rolled over
if(millis()-lastTime > 1000 || millis() < lastTime) {
// rightshift to divide by two because isr is triggered on a change, but we want rising
int blips = blipsSeen;
flow = blips/4.8;
dtostrf(flow, 4, 2, flowString);
//sprintf(flowString, "%d", blips);
blipsSeen = 0;
lastTime = millis();
}
}
void setup() {
setupFlowSensor();
TinyWire.begin(mAddr);
TinyWire.onRequest(i2cISR);
}
void loop() {
estimateFlow();
}