Hi,
I want to port a project from Arduino 2560 to Teensy 3.2 with a 3rd party library SimpleSDAudio.
I'm advancing step by step. Replacing fast PWM on Arduino with IntervalTimer and DAC works. Now I want to port the SD part which is a simplified version of SDFat and very fast.
The code of the first step is:
#include "audio.h"
//#include <sd_l2.h>
elapsedMicros blinkPrint=0;
uint16_t looping=0;
byte isr_disen =0;
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
SdPlay.init();
Serial.print("Symbol ARDUINO = ");Serial.println(ARDUINO);
}
void loop() {
unsigned long blinkCopy; // holds a copy of the blinkCount
// to read a variable which the interrupt code writes, we
// must temporarily disable interrupts, to be sure it will
// not change while we are reading. To minimize the time
// with interrupts off, just quickly make a copy, and then
// use the copy while allowing the interrupt to keep working.
delay(50);
if (blinkPrint > 1000000) { // every second
blinkPrint = 0;
noInterrupts();
blinkCopy = SdPlay.blinkCount;
interrupts();
Serial.print("blinkCount = ");
Serial.print(blinkCopy);
Serial.print(" isr_disen=");Serial.println(isr_disen);
if (isr_disen) {
SdPlay.start(); // method 4
isr_disen=0;
}
else {
SdPlay.stop(); // method 4
isr_disen=1;
}
looping++;
}
}
I works. The IntervalTimer is started in setup() with SdPlay.init() and the LED is blinking for 1 sec, then stops blinking for 1 sec, and so on.
Next the line //#include <sd_l2.h> in the beginning is decommented. And now the compiler reports a lot of errors in core libraries, like
...\arduino-1.8.4\hardware\tools\arm\arm-none-eabi\include\machine\_default_types.h: Assembler messages:
...\arduino-1.8.4\hardware\tools\arm\arm-none-eabi\include\machine\_default_types.h:27: Error: bad instruction `typedef signed char __int8_t'
...\arduino-1.8.4\hardware\tools\arm\arm-none-eabi\include\machine\_default_types.h:29: Error: bad instruction `typedef unsigned char __uint8_t'
The part of code in _default_types.h with the reported error of the example (lines 27, 29 marked):
/*
* $Id$
*/
#ifndef _MACHINE__DEFAULT_TYPES_H
#define _MACHINE__DEFAULT_TYPES_H
#include <sys/features.h>
/*
* Guess on types by examining *_MIN / *_MAX defines.
*/
#if __GNUC_PREREQ (3, 3)
/* GCC >= 3.3.0 has __<val>__ implicitly defined. */
#define __EXP(x) __##x##__
#else
/* Fall back to POSIX versions from <limits.h> */
#define __EXP(x) x
#include <limits.h>
#endif
#ifdef __cplusplus
extern "C" {
#endif
#ifdef __INT8_TYPE__
typedef __INT8_TYPE__ __int8_t; <----------------line 27
#ifdef __UINT8_TYPE__
typedef __UINT8_TYPE__ __uint8_t; <----------------line 29
#else
typedef unsigned __INT8_TYPE__ __uint8_t;
#endif
Similar errors are reported in other header files of the core library.
Also such type of error is reported:
...\arduino-1.8.4\hardware\teensy\avr\cores\teensy3\kinetis.h:146: Error: bad instruction `enum IRQ_NUMBER_t {'
...\arduino-1.8.4\hardware\teensy\avr\cores\teensy3\kinetis.h:147: Error: junk at end of line, first unrecognized character is `,'
...\arduino-1.8.4\hardware\teensy\avr\cores\teensy3\kinetis.h:148: Error: junk at end of line, first unrecognized character is `,'
Lines 144 - 150 of kinetis.h where the errors are reported from:
// Teensy 3.1 & 3.2
#elif defined(__MK20DX256__)
enum IRQ_NUMBER_t {
IRQ_DMA_CH0 = 0,
IRQ_DMA_CH1 = 1,
IRQ_DMA_CH2 = 2,
IRQ_DMA_CH3 = 3,
I don't understand these error messages at all. What about such curious error messages in core libraries!
Compilation for Arduino is ok, but not for Teensy.
Is there a different compiler for Arduino and Teensy?
It's not a matter of non matching libraries. What to do now?
supArdu