Hi,
i want to build a Programmable CDI Ignition System for my Scooter with a Attiny85 µC.
the timing for Ignition is stored in the EEprom and should be changeable through a Serial connection (Arduino nano <-> attiny).
the ignition is triggered through a Pin Change Interrupt ISR on pin RB0, but if i include the Software Serial lib. i cant compile the sketch:
libraries\SoftwareSerial\SoftwareSerial.cpp.o (symbol from plugin): In function `SoftwareSerial::read()':
(.text+0x0): multiple definition of `__vector_2'
sketch\CDI.ino.cpp.o (symbol from plugin):(.text+0x0): first defined here
collect2.exe: error: ld returned 1 exit status
exit status 1
Fehler beim Kompilieren für das Board ATtiny25/45/85.
here is the sketch:
#include "avr/interrupt.h"
#include <EEPROM.h>
#include <SoftwareSerial.h>
//PICKUP = PB0
#define IGCOIL 1
#define RXPIN 2
#define TXPIN 3
unsigned int igdelay[150]; //[1] = 100rpm, [2] = 200rpm ...
volatile unsigned long revtime;
volatile int rpm;
volatile byte igindex;
SoftwareSerial softSerial(RXPIN, TXPIN);
void setup() {
if(digitalRead(RXPIN)) serialconsole(); //the ignition should only be programable if RXPIN is High on startup
else{
readEE();
GIMSK |= 0b00100000; //turns on pin change interrupts
PCMSK |= 0b00000001; //turn on interrupt on PB0
sei(); //enable interrupts
pinMode(IGCOIL, OUTPUT);
}
}
void loop(){} //Do nothing...
ISR(PCINT0_vect){
if(digitalRead(0)){ //only run when RB0 = High
rpm = 1000000 / (micros() - revtime) * 60;
revtime = micros();
igindex = rpm / 1000;
delayMicroseconds(igdelay[igindex]);
digitalWrite(IGCOIL, HIGH);
delay(1);
digitalWrite(IGCOIL, LOW);
}
}
void readEE(){
for(int i = 0; i < 148; i++){
igdelay[i] = EEPROM.read(i);
}
}
void writeEE(){
for(int i = 0; i < 148; i++){
EEPROM.update(i, igdelay[i]);
}
}
void serialconsole(){
softSerial.begin(9600);
softSerial.print("1");
while(1){
//not finished yet...
}
}
or is there another communication method between two arduinos (eg. i2c, SPI..)