Skip to content

Commit 731ac3d

Browse files
committed
msp430x5xx: Add fix for possible bug in msp430-elf-gcc 9.3.0.
1 parent f4efb51 commit 731ac3d

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/portable/ti/msp430x5xx/dcd_msp430x5xx.c

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -623,7 +623,18 @@ void dcd_int_handler(uint8_t rhport)
623623
handle_setup_packet();
624624
}
625625

626-
uint16_t curr_vector = USBVECINT;
626+
// Workaround possible bug in MSP430 GCC 9.3.0 where volatile variable
627+
// USBVECINT is read from twice when only once is intended. The second
628+
// (garbage) read seems to be triggered by certain switch statement
629+
// configurations.
630+
uint16_t curr_vector;
631+
#if __GNUC__ > 9 || (__GNUC__ == 9 && __GNUC_MINOR__ > 2)
632+
asm volatile ("mov %1, %0"
633+
: "=r" (curr_vector)
634+
: "m" (USBVECINT));
635+
#else
636+
curr_vector = USBVECINT;
637+
#endif
627638

628639
switch(curr_vector)
629640
{

0 commit comments

Comments
 (0)