Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 12 of 12

Thread: Audio board for Teensy4

Hybrid View

  1. #1
    Senior Member
    Join Date
    May 2017
    Location
    Netherlands
    Posts
    104

    Audio board for Teensy4

    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);

  2. #2
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    21,323
    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.

  3. #3
    Senior Member
    Join Date
    May 2017
    Location
    Netherlands
    Posts
    104

    Audio board

    The zip file with the projectCwModem-v2-beta20171110a.zip
    Last edited by pd0lew; 12-18-2019 at 10:41 AM. Reason: No attachement added

  4. #4
    Senior Member
    Join Date
    May 2017
    Location
    Netherlands
    Posts
    104
    Ok but it's a big file can I use a zip file?

  5. #5
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    21,323
    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.

  6. #6
    Senior Member
    Join Date
    May 2017
    Location
    Netherlands
    Posts
    104
    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)));

  7. #7
    Senior Member
    Join Date
    May 2017
    Location
    Netherlands
    Posts
    104
    Perhaps nothing to do with the audio, there is something else that gives compile errors..

  8. #8
    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.

  9. #9
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    21,323
    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.

  10. #10
    Senior Member
    Join Date
    Nov 2012
    Posts
    1,219
    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.

  11. #11
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    21,323
    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)

  12. #12
    Senior Member
    Join Date
    May 2017
    Location
    Netherlands
    Posts
    104
    Hi Paul,

    Yes it compiles, now testing the stuff.

    Thank you like always.

    Best regards,
    Johan

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •