PDA

View Full Version : Basic question on Teensy++ 2.0 interrupts



Nightowl
11-26-2012, 11:25 PM
Hello from Switzerland.

I am on several personnal projects around my boat based on a Teensy. To start with, I selected the Teensy++ 2.0 in order to learn (while computer literate, I'm brand new to microcontrollers ! Just started a month ago).

My projects involve several type of sensors and wireless communication capabilities. I have read (and again, this several times) most of the pages on the PJRC site, looked at Arduino libraries, examples, etc, before diving in a project. I tried all the example I could find to get some feeling about the language (never used C++ before) and different way of wiring stuff. So far so good !

The first one is with a GSM modem, and some sensors, and so far setting up the hardware and software worked well, uart usage included, even added and used new libraries to the development environment. Thanks to all the explanation we can find on PJRC and Arduino sites.

So that was to introduce a bit what I am up to.

Context:
- Arduino V1.0.1
- Teensyduino (from PJRC link)
- While I tried once an example to compile/link with WinAVR, I use only Teensyduino.

So now I wanted to start using interrupts. So I looked around, read (partly the Atmel datasheet), found some examples and started from there. Got an example working and wanted to extrapolate from it and include it in my program.

As my code is structured around the setup() and loop() sketch functions, I looked at including bits of the example code with interrupts (from PJRC and other sites) into it. But this does not seem to work ! One example I used is based on a main() function, without "setup() and loop()".

Now the question : Is there a possibility to code interrupt definitions and one or more interrupt macros within the "setup() and loop()" program layout ? Or do I need to have a main() function, and articulate my main loop into a while or something like that !
(if yes would be interested to understand why).

So thanks, if that question is not appropriate for a new thread or this forum, to tell me.