how to use GDB with teensy 3.2?

Status
Not open for further replies.
Hi,
I'm planning to make a robot with the Teensy 3.2.
And when I debug it, I really don't want to put in printf statements or wire up an led just to see where's wrong.
Is there any way to connect a JTAG or SWD debugger and run GDB to debug my teensy 3.2?


Thanks!

P.S. Also, How can I program the Teensy 3.2 in C, not arduino?
 
There are hacks manually wiring not sure if posted on forum but I saw one purporting to work. Of course doing that is way more work to do and maintain or set up than "wire up an led just to see where's wrong". No doubt official debug support would be a better answer at times but it isn't part of Arduino or Teensy. Though it is planned to be supported using exposed hardware pins on T_3.5 and T_3.6 that don't exist on T_3.2 - no declaration of when yet . . .

Arduino is just an IDE front end to a C/C++ compiler. PJRC happens to have used it and follows their standards to set up the Teensy to be ready to run and use. Full sources are included to add/remove C/C++ code and do what you want with the MCU.
 
Note, the Arduino language is C++ with some simplifications (such as a pre-pass to provide forward declarations).

If you want to program in straight C++, but use the Arduino framework, create a library, such as Foo, with Foo.h and Foo.cpp in the library directory. From your Arduino sketch do something like:

Code:
#include <Foo.h>

void setup (void) { FooSetup (); }
void loop (void) { FooLoop (); }

and in Foo.h:

Code:
#include <Arduino.h>

extern void FooSetup (void);
extern void FooLoop (void);

and in Foo.cpp:

Code:
#include <Foo.h>

void FooSetup (void)
{
  // whatever you need to do at the start of the program
}

void FooLoop (void)
{
  // whatever you need to do everytime through the loop
}

You can create a C file as well with the .c suffix. However, since the various files are written in C++, you may have to have a C++ layer (using extern "C" { ... } for the C files to call.
 
Status
Not open for further replies.
Back
Top