WorldFamousElectronics / PulseSensor_Amped_Arduino

PulseSensor Arduino code for BPM and Processing-Visualizer
MIT License
238 stars 206 forks source link

Example code does not compile on either Arduino Zero or MKR1000 #24

Open viggi1000 opened 8 years ago

viggi1000 commented 8 years ago

Hey guys, I work on hobby projects mostly and got the Pulse sensor to do some biomedical hacks. While the example works on the older Arduino's(Mega,UNO), The code throws a lot of errors with newer arduino's like Arduino Zero, MKR1000 or the Adafruit M0 feather.

Will you guys be porting the code to newer arduino's? The sensor works great and would be awesome to work with this in the MKR1000's or the new arduino's. I'm unfamiliar with interrupts and stuff so I couldn't get it working again, I would really appreciate any help!

Here is the compilation error


Interrupt:27: error: expected constructor, destructor, or type conversion before '(' token
 ISR(TIMER2_COMPA_vect){                         // triggered when Timer2 counts to 124
     ^
/Users/ravichandranv/Desktop/PulseSensor_Amped_Arduino-master/PulseSensorAmped_Arduino_1dot4/Interrupt.ino: In function 'void interruptSetup()':
Interrupt:17: error: 'TCCR2A' was not declared in this scope
   TCCR2A = 0x02;     // DISABLE PWM ON DIGITAL PINS 3 AND 11, AND GO INTO CTC MODE
   ^
Interrupt:18: error: 'TCCR2B' was not declared in this scope
   TCCR2B = 0x06;     // DON'T FORCE COMPARE, 256 PRESCALER 
   ^
Interrupt:19: error: 'OCR2A' was not declared in this scope
   OCR2A = 0X7C;      // SET THE TOP OF THE COUNT TO 124 FOR 500Hz SAMPLE RATE
   ^
Interrupt:20: error: 'TIMSK2' was not declared in this scope
   TIMSK2 = 0x02;     // ENABLE INTERRUPT ON MATCH BETWEEN TIMER2 AND OCR2A
   ^
Interrupt:21: error: 'sei' was not declared in this scope
   sei();             // MAKE SURE GLOBAL INTERRUPTS ARE ENABLED      
       ^
/Users/ravichandranv/Desktop/PulseSensor_Amped_Arduino-master/PulseSensorAmped_Arduino_1dot4/Interrupt.ino: At global scope:
Interrupt:27: error: expected constructor, destructor, or type conversion before '(' token
 ISR(TIMER2_COMPA_vect){                         // triggered when Timer2 counts to 124
    ^
exit status 1
expected constructor, destructor, or type conversion before '(' token
viggi1000 commented 8 years ago

:Bump:

morefigs commented 8 years ago

The timer interrupts are different between the two chip types (AVR vs SAM). The library used in the source code doesn't know about the boards you're trying.

freethinkerjcj commented 4 years ago

@morefigs thanks for stating the obvious. It very clear from the question that is the problem. Why not suggest a solution?

biomurph commented 4 years ago

If you're using an ARM uC, then please use the BPM_Alternative example sketch.