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

Thread: NRF24L01 and Teensy 3.1

  1. #1
    Senior Member
    Join Date
    Mar 2015
    Location
    UK
    Posts
    370

    NRF24L01 and Teensy 3.1

    Just started with NRF24L01. Not used these boards before. Hit a compile issue with "Serial.printf".

    I have modified some code that I already use the SPI bus for on an ADF4351 board (which works fine). I have included two new "includes" as shown here...
    #include <stdint.h>
    #include <SPI.h>
    #include <nRF24L01.h> //new
    #include <RF24.h> //new

    The code imported was from another forum post which directed me to...
    https://lastminuteengineers.com/nrf2...communication/

    The only real difference between my own code and the imported "lastminuteengineers" code is that I already have defined "Serial.begin(115200);" so deleted their Serial.begin in the receive section.

    Now here is my compile error. It seems to me that my own "Serial.printf" may be clashing with a "#define printf Serial.printf", but I don't fully understand the error message. If I comment out the line shown as Line 179, then it complies OK with just a warning. Any help would be appreciated...

    Click image for larger version. 

Name:	Error 01.jpg 
Views:	13 
Size:	74.4 KB 
ID:	22199

  2. #2
    Senior Member+ KurtE's Avatar
    Join Date
    Jan 2014
    Posts
    7,917
    Yep - if there is a line defined like:

    #define printf Serial.printf

    and later you yourself do something like: Serial.printf("a");

    And assuming simple case where it does not rescan, the line and infinite recurse, the like then looks like:
    Serial.Serial.printf("a");

    Again think of #define used as simple text substitution.

    In your case, what happens if you just then do printf("%06d\r\n", xxx)

  3. #3
    Senior Member PaulS's Avatar
    Join Date
    Apr 2015
    Location
    Netherlands
    Posts
    335
    Yeah, ran into the same error when wanting to output formatted data using Serial.printf.
    Just use printf instead of Serial.printf, like Kurt suggested.

    Paul

  4. #4
    Senior Member
    Join Date
    Mar 2015
    Location
    UK
    Posts
    370
    Worked beautifully. Thank you.

Posting Permissions

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