Audio board for Teensy4

Status
Not open for further replies.

pd0lew

Well-known member
Hi all,

I like to use my program for a Teensy 4.0 was used for a Teensy 3.2 and works.
This is the code for the 3.2 but it gives compile errors on a T4 so what must be changed to get this working on a T4

Please help!
Best,
Johan


// GUItool: begin automatically generated code
AudioControlSGTL5000 sgtl5000;
AudioInputI2S i2sIn;
AudioFilterBiquad iirIn;
AudioRecordQueue inQueue;
AudioAnalyzePeak peakIn;
AudioConnection patchCord1(i2sIn, 0, iirIn, 0);
AudioConnection patchCord2(iirIn, inQueue);
AudioConnection patchCord3(iirIn, peakIn);
 
To get help here, you need to show the complete program, so anyone can copy it into Arduino and click Verify to see the same error you're getting.

When we can't reproduce the error, or even see it, there's little that can be done to help.
 
Please delete as much of the code as possible. If there really is a compile error in one of the libraries, odds are very good most of your program doesn't need to be present to reproduce the error. Just delete parts of your program and keep clicking Verify to see if the error remains. Easy stuff!

And to answer your question, yes, you can post a zip file here. If using "quick reply", click the "Go Advanced" button. The advanced editor lets to attach a file to your message.

However, using the code tags (the "#" button in the editor's toolbar) is almost always a better choice. Many more people will see your code if you post it that way.
 
When compiling I get this info :

/tmp/arduino_build_162599/sketch/CwDecoderLogic.h:210:42: note: in expansion of macro 'PSTR'
*bp++ = MakeTableEntry(strcpy_P(fbuf, PSTR("........")), '\x7F');

^
/home/holstein/arduino-1.8.10/hardware/teensy/avr/cores/teensy4/avr/pgmspace.h:30:39: note: 'data' was declared here
#define PSTR(str) ({static const char data[] PROGMEM = (str); &data[0];})
^
/home/holstein/arduino-1.8.10/hardware/teensy/avr/cores/teensy4/avr/pgmspace.h:55:45: note: in definition of macro 'strcpy_P'
#define strcpy_P(dest, src) strcpy((dest), (src))
^
/home/holstein/Desktop/CwModem/CwModem.ino:638:42: note: in expansion of macro 'PSTR'
HostSerial.print(strcpy_P(ioBuffer, PSTR(LOCAL_CRLF)));
 
It seems the problem with the PSTR macro (string in flashmemory) might be caused by the different organisation of memory in t4 compared to t3.x

Just a guess. I 'm sure Paul can check this easily.
 
I tried this quick sanity test, just to make sure strcpy_P and PSTR really do work.

Code:
void setup() {
}

void loop() {
  char buf[256];
  strcpy_P(buf, PSTR("hello world"));
  Serial.println(buf);
  delay(500);
}

They do, as you can see if you copy this into Arduino and run it on a Teensy 4.0.
 
Adding this code at the top of CWModem.ino will remove the error messages. I don't know if it will produce working code though - there may be other problems with memory spaces still to be resolved, but give it a try.
Code:
#ifdef strcpy_P
#undef strcpy_P
#define strcpy_P strcpy
#endif

Pete
#ifdef PSTR
#undef PSTR
#define PSTR
#endif

Pete
P.S. Paul's message #9 wasn't there when I posted this. The forum software has done this to me before.
 
Looking at this code now. I believe this is the same section type conflict problem we saw with using PROGMEM on both functions and variables in the same file. They go into different "sections" and the compiler get very unhappy if 2 things in 2 different sections within the same file try to allocate variables in a particular 3rd section ("progmem"). In this case, it's normal code vs static constructor code, which the compiler puts into a special section.

I'm afraid there probably is no good solution we can do in the definition of PSTR. Best thing to do is just add this to the beginning of your program:

Code:
#undef PSTR
#define PSTR(s) (s)
 
Status
Not open for further replies.
Back
Top