Some basic help needed to get started with teensy LC board

Status
Not open for further replies.

arbj

Member
Hi,

I just bought some TeensyLC boards. I have downloaded the loader program for Ubuntu and this is working well with the board. The push button is detected by the program. Also I loaded blink_fast_TeensyLC.hex file and this also worked.

I am trying to develop a hello world program by blinking the LED on the board, every 5 seconds.
For this I made the following code. I am not sure whether it is entirely correct.

#include <avr/io.h>
#include <util/delay.h>

// Teensy 2.0: LED is active high
#if defined(__AVR_ATmega32__) || defined(__AVR_AT90USB1286__)
#define LED_ON (PORTD |= (1<<6))
#define LED_OFF (PORTD &= ~(1<<6))

// Teensy 1.0: LED is active low
#else
#define LED_ON (PORTD &= ~(1<<6))
#define LED_OFF (PORTD |= (1<<6))
#endif

#define LED_CONFIG (DDRD |= (1<<6))
#define CPU_PRESCALE(n) (CLKPR = 0x80, CLKPR = (n))

#define LED_CONFIG (DDRD |= (1<<6))
#define CPU_PRESCALE(n) (CLKPR = 0x80, CLKPR = (n))

int main(void){

int b=1;

CPU_PRESCALE(0);
LED_CONFIG;
LED_OFF;

while (1){

if (b==1){

LED_ON;
b=0;
}
else{

LED_OFF;
b=1;
}

_delay_ms(5000);
}

return 0;

}

I copied some parts from the blink.c program. I am unable to get the command line parameters to be used for the avr-gcc command line tool.

I am using this...

avr-gcc -w -Os -DF_CPU=1600000UL -mmcu=atmega32 -c -o test.o test.c
avr-gcc -w -mmcu=atmega32 test.o -o test
avr-objcopy -O ihex -R .eeprom test test.hex

However nothing seems to happen the normal blinking program on the TeensyLC (loaded by default) stops working and the LED does not light up as desired.

Please help....what is going wrong here ??


thanks
a
 
You're using code and commands for the old 8 bit AVR boards. Teensy-LC is based on a 32 bit ARM chip.

Use Arduino with Teensyduino. Open the blink example, with File > Examples > 01.Basics > Blink.

Make sure you select Teensy-LC in the Tools > Boards menu before you upload.
 
thanks for the help,

is there any way of using C or C++ instead of Arduino Code ??

Could you please also recommend some C/C++ compilers and IDEs that can be suitable for the TeensyLC...

I have Eclipse installed (using Ubuntu 12.04), I am meanwhile searching the net...

thanks
a
 
Last edited:
Arduino is C++

If you want to compile without the Arduino GUI, there's a sample makefile installed within hardware/teensy/avr/cores/teensy3. You MUST download Arduino and install Teensyduino to get it, but then you can use make to compile without running Arduino.
 
Thanks, that helped me a lot.

Is Kinetis Development Studio suitable for the TeensyLC ??
 
Last edited:
OK I got it working now...

I have downloaded Kinetis Development Studio (both IDE and the SDK) for Linux on my computer (both Windows and Linux work well) . I can now develop code for the teensyLC board using the Kinetis IDE and SDK. The procedure is simple enough, create a new Kinetis Studio Project, selecting the processor, then using the processor expert option to create the code.

Using the Component Inspector it is possible to add code for I2C, UART and general GPIO. Using this procedure I can make a simple Hello World program for the TeensyLC board, the hello world program makes the LED on the teensyLC board blink. For this the Wait component will also have to be installed.

I thought this may be useful for users who need to develop non-arduiono based code.

I am now going to develop some code for the MCP23016/23017 I/O expander IC, and the 24LC256 EEPROM.

thanks
a
 
OK I got it working now...

I have downloaded Kinetis Development Studio (both IDE and the SDK) for Linux on my computer (both Windows and Linux work well) . I can now develop code for the teensyLC board using the Kinetis IDE and SDK. The procedure is simple enough, create a new Kinetis Studio Project, selecting the processor, then using the processor expert option to create the code.

Using the Component Inspector it is possible to add code for I2C, UART and general GPIO. Using this procedure I can make a simple Hello World program for the TeensyLC board, the hello world program makes the LED on the teensyLC board blink. For this the Wait component will also have to be installed.

I thought this may be useful for users who need to develop non-arduiono based code.

I am now going to develop some code for the MCP23016/23017 I/O expander IC, and the 24LC256 EEPROM.

thanks
a

There is a eeprom-Emulation in the Teensy-"Arduino" code.
 
OK I got it working now...

I have downloaded Kinetis Development Studio (both IDE and the SDK) for Linux on my computer (both Windows and Linux work well) . I can now develop code for the teensyLC board using the Kinetis IDE and SDK. The procedure is simple enough, create a new Kinetis Studio Project, selecting the processor, then using the processor expert option to create the code.

Using the Component Inspector it is possible to add code for I2C, UART and general GPIO. Using this procedure I can make a simple Hello World program for the TeensyLC board, the hello world program makes the LED on the teensyLC board blink. For this the Wait component will also have to be installed.

I thought this may be useful for users who need to develop non-arduiono based code.

I am now going to develop some code for the MCP23016/23017 I/O expander IC, and the 24LC256 EEPROM.

thanks
a

I did a small library for the 24LC512 . It should work for the 24LC256 as well.
 
OK I got it working now...

I have downloaded Kinetis Development Studio (both IDE and the SDK) for Linux on my computer (both Windows and Linux work well) . I can now develop code for the teensyLC board using the Kinetis IDE and SDK. The procedure is simple enough, create a new Kinetis Studio Project, selecting the processor, then using the processor expert option to create the code.

Using the Component Inspector it is possible to add code for I2C, UART and general GPIO. Using this procedure I can make a simple Hello World program for the TeensyLC board, the hello world program makes the LED on the teensyLC board blink. For this the Wait component will also have to be installed.

I thought this may be useful for users who need to develop non-arduiono based code.

I am now going to develop some code for the MCP23016/23017 I/O expander IC, and the 24LC256 EEPROM.

thanks
a
I've used the KDS (and its peers for other MCUs). Teensy is focused on reuse of and expanding the Arduino libraries at the source code level. Using KDS means you won't get that benefit.
 
KDS is Eclipse + GCC, so yes.
Front end, optional, is Processor Expert (PE). It is a plugin for Eclipse. It's GUI and wizards enable one, with patience, to build a pin mapping of alternate functions and pin settings, timer configs, DMA/Interrupt configs. Then generate code.
I used KDS+PE twice now. I found it unusable for several reasons (except for simple cases).

I have lots of time with ST's equivalent: CubeMX (what PE should have been). It targets Keil, IAR, Attloic and new last month, an ST version of Eclipse with CubeMX.
I can elaborate on how ST/Freescale's CubeMX/PE compare, and how libraries compare but won't, in this Freescale oriented venue. Vast difference, in ST's favor, esp. in completeness of driver libraries. One really doesn't need to write ANY drivers these days, when using the on-chip devices in interrupt, polling, or DMA modes.
 
Last edited:
Status
Not open for further replies.
Back
Top