From eee92c6cf17b65477cdf13d4643cc0e80aeacdec Mon Sep 17 00:00:00 2001 From: Gerardo Marx Date: Fri, 7 Oct 2022 07:45:42 -0500 Subject: [PATCH] Basic test Ok --- Readme.md | 103 +++++++++++++++++++++++++++++++++++++++++++++++++++++ main.c | 18 ++++++++++ msp430.dat | 6 ++++ 3 files changed, 127 insertions(+) create mode 100644 Readme.md create mode 100644 main.c create mode 100644 msp430.dat diff --git a/Readme.md b/Readme.md new file mode 100644 index 0000000..bf95f49 --- /dev/null +++ b/Readme.md @@ -0,0 +1,103 @@ +# Introduction +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. + +# The repository +This repository includes the `main.c` and `msp430.dat` files required to accomplish the compilation and debuging process. + +## The Code `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 +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(); + } + } +} +``` + +## The `msp430.dat` +The content of `msp430.dat` configures the communication between computer and the launchpad. + +Add more description later + +# Compiling + +``` +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 +``` + +# Debuging + +``` +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. + + +# Problems: + +``` +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 +``` + diff --git a/main.c b/main.c new file mode 100644 index 0000000..cf2d5da --- /dev/null +++ b/main.c @@ -0,0 +1,18 @@ +#include +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(); + } + } +} diff --git a/msp430.dat b/msp430.dat new file mode 100644 index 0000000..f470e42 --- /dev/null +++ b/msp430.dat @@ -0,0 +1,6 @@ +# config version=3.5 +$ msp430 + msp430_drvr=msp430.dll + msp430_port=TIUSB + msp430_vcc=3.3 +$ /