Gerardo Marx Chávez-Campos 1065e04c4a | 2 years ago | |
---|---|---|
Makefile | 2 years ago | |
Readme.md | 2 years ago | |
main.c | 2 years ago | |
msp430.dat | 2 years ago |
Basic code to Blink the LED on the MSP430 F5529 Launchpad Evaluation Kit MSP-EXP430F5529LP from Texas Instruments, using the GCC tool-chain from terminal.
This repository includes the main.c
and msp430.dat
files required to accomplish the compilation and debuging process.
main.c
The example code blinks the on board LED attached to P1.0, you can copy the contents from here or clone use the file included in the repository:
#include <msp430f5529.h>
void main(void)
{
WDTCTL = WDTPW | WDTHOLD; // stop watchdog timer
// PM5CTL0 = 0x0000; // disable high impedance mode
P1DIR = 0x01; //set up bit 0 of P1 as output
P1OUT = 0x00; //initialize bit 0 of P1 to 0
for(;;){ //loop
volatile unsigned int i;
P1OUT ^= 0x01; //toggle bit 0 of P1
//Delay
for(i=40000; i>0;){
i--;
__no_operation();
}
}
}
msp430.dat
The content of msp430.dat
configures the communication between computer and the launchpad.
Add more description later
export PATH="/home/gmarx/msp430-gcc/bin:$PATH"
msp430-elf-gcc -I /home/gmarx/msp430-gcc/include -L /home/gmarx/msp430-gcc/include -mmcu=msp430f5529 -O2 -g main.c -o main.o
gdb_agent_console msp430.dat
CPU Name Port
-------- ----
msp430 :55000
Starting all cores
CPU Name Status
-------- ------
msp430 Waiting for client
In a new terminal tab or window:
msp430-elf-gdb --tui main.o
(gdb) target remote :55000
Remote debugging using :55000
0x00004400 in __crt0_start ()
The agent will response in the other terminal:
msp430 Client connected...Connecting to Target
Found USB FET at ttyACM0
Target connected...Starting server
Then, continue in the gdb terminal prompt:
(gdb) load
Loading section .lowtext, size 0xa lma 0x4400
Loading section .text, size 0x2e lma 0x440a
Loading section __reset_vector, size 0x2 lma 0xfffe
Start address 0x00004400, load size 58
Transfer rate: 38 bytes/sec, 19 bytes/write.
(gdb) b 1
Breakpoint 1 at 0x440c: file main.c, line 4.
(gdb) continue
Continuing.
Breakpoint 1, main () at main.c:4
(gdb) s 1
and you will see the code in the terminal running step by step, or write continue
to observe the LED blinking on the Launch pad board.
msp430-elf-gdb main.o
msp430-elf-gdb: error while loading shared libraries: libncursesw.so.5: cannot open shared object file: No such file or directory
yay -S ncurses5-compat-libs