Hi there,
I researched the issue quite a bit and mainly followed this guide:
http://www.ti.com/lit/an/slaa452b/slaa452b.pdf
Basically I want to trigger the USB BSL from the main program when a user button is pressed, so I can flash a new firmware using the "MSP430 USB Firmware Upgrade Example" (Isn't there actually another way of flashing a new firmware using usb??). I figured that you need to call 0x1000, however I'm experiencing some strange behaviour.
#include <msp430.h>
extern void invkBsl(void);
void invokeBSL(void)
{
// SYSBSLC &= ~(SYSBSLPE);
PJOUT &= ~BIT0; // disable LED1 to show that function has been called
//disable interrupts
__disable_interrupt();
// enter BSL
//((void (*)())0x1000)(); // Invoke BSL
invkBsl(); // calla #0x1000
}
int main(void)
{
WDTCTL = WDTPW+WDTHOLD; // Stop WDT
PJDIR |= 0xF; // PJ.0 set as output
P6DIR = ~BIT0; // Set P6.0 Switch as Input
P6REN = 0x00; // Disable Pullup, as it is implemented in hardware.
PJOUT |= BIT0; // Turn on Status LED 1
PJOUT |= BIT1; // Turn on Status LED 2
while(1) // continuous loop
{
if(P6IN & BIT0 == 0)
invokeBSL(); // Invoke BSL when button is pressed
PJOUT = (P6IN << 1) | (PJOUT & BIT0); // Set LED2 to current Switch status
}
}
right, now as you can see, what I expect to happen is that i press the button, Status LED1 and LED2 turns off (LED1 permanently, LED2 until button is released) and my pc should find the MSP430 as a usb device, ready to be flashed using the software tool.
Now what happens is this: LED1 is still on, LED2 turns off as long the button is beeing pressed. My explanation: The BSL is called and instantly returnes control to the main program, reactivating LED1 instantly.
So why doesn't the BSL do what happens when I pull up the PUR pin while connecting the board via usb??
Regards,
Max