It looks like the problem is using the yellow led in your interrupt code. The boardService() function calls boardStartBootloaderIfNeeded(), and it will then see that the yellow LED (P2_2) is on. Because it will read P2_2 as high, it will start boardStartBootloader() and go into a boot loader state. Below is a code that toggles the red LED with an overflow timer interrupt on Timer 3. (I also noticed that you had EN = 1 in your interrupt settings code and changed it to EA = 1.)
#include <wixel.h>
#include <usb.h>
#include <usb_com.h>
void timer3Init()
{
T3CCTL1 = T3CCTL0 = 0; // Disable timer compare interrupts.
T3CTL = 0b11111100; // Configure and start Timer 3.
T3IE = 1; // Enable the Timer 3 interrupt.
EA = 1; // Enable interrupts in general.
}
ISR(T3, 0)
{
// T3IF is cleared automatically and we don't need to clear T3OVFIF.
LED_RED_TOGGLE();
}
void main()
{
systemInit();
usbInit();
timer3Init();
while(1)
{
usbShowStatusWithGreenLed();
boardService();
usbComService();
}
}
Thank you Jeremy, that was the problem, it was entering boat loader mode, good catch ! - maybe agood idea to add this to the wixel documentation, so you dont cause this “accidents” when using that pin as I/O. This is a great controller, so many peripherals and options, you guys should promote it more, it is very capable and flexible.
Hello. I would like to add that you can use the yellow LED pin (P2_2) as an I/O line, but if you do it from an interrupt then you should avoid calling boardService().
If you don’t call boardService, then app will no longer detect you shorting P2_2 to 3V3 and launch the bootloader. That shouldn’t be a big problem, because there are two other ways to get into bootloader mode: a USB command, and shorting those pins together when the board starts up. The source code of boardService is pretty simple so I would just recommend reading it: