Basic example of the GCC usage on linux
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

103 lines
2.5 KiB

1 year ago
  1. # Introduction
  2. 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.
  3. # The repository
  4. This repository includes the `main.c` and `msp430.dat` files required to accomplish the compilation and debuging process.
  5. ## The Code `main.c`
  6. 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:
  7. ```
  8. #include <msp430f5529.h>
  9. void main(void)
  10. {
  11. WDTCTL = WDTPW | WDTHOLD; // stop watchdog timer
  12. // PM5CTL0 = 0x0000; // disable high impedance mode
  13. P1DIR = 0x01; //set up bit 0 of P1 as output
  14. P1OUT = 0x00; //initialize bit 0 of P1 to 0
  15. for(;;){ //loop
  16. volatile unsigned int i;
  17. P1OUT ^= 0x01; //toggle bit 0 of P1
  18. //Delay
  19. for(i=40000; i>0;){
  20. i--;
  21. __no_operation();
  22. }
  23. }
  24. }
  25. ```
  26. ## The `msp430.dat`
  27. The content of `msp430.dat` configures the communication between computer and the launchpad.
  28. Add more description later
  29. # Compiling
  30. ```
  31. export PATH="/home/gmarx/msp430-gcc/bin:$PATH"
  32. msp430-elf-gcc -I /home/gmarx/msp430-gcc/include -L /home/gmarx/msp430-gcc/include -mmcu=msp430f5529 -O2 -g main.c -o main.o
  33. ```
  34. # Debuging
  35. ```
  36. gdb_agent_console msp430.dat
  37. CPU Name Port
  38. -------- ----
  39. msp430 :55000
  40. Starting all cores
  41. CPU Name Status
  42. -------- ------
  43. msp430 Waiting for client
  44. ```
  45. In a new terminal tab or window:
  46. ```
  47. msp430-elf-gdb --tui main.o
  48. (gdb) target remote :55000
  49. Remote debugging using :55000
  50. 0x00004400 in __crt0_start ()
  51. ```
  52. The agent will response in the other terminal:
  53. ```
  54. msp430 Client connected...Connecting to Target
  55. Found USB FET at ttyACM0
  56. Target connected...Starting server
  57. ```
  58. Then, continue in the gdb terminal prompt:
  59. ```
  60. (gdb) load
  61. Loading section .lowtext, size 0xa lma 0x4400
  62. Loading section .text, size 0x2e lma 0x440a
  63. Loading section __reset_vector, size 0x2 lma 0xfffe
  64. Start address 0x00004400, load size 58
  65. Transfer rate: 38 bytes/sec, 19 bytes/write.
  66. (gdb) b 1
  67. Breakpoint 1 at 0x440c: file main.c, line 4.
  68. (gdb) continue
  69. Continuing.
  70. Breakpoint 1, main () at main.c:4
  71. (gdb) s 1
  72. ```
  73. 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.
  74. # Problems:
  75. ```
  76. msp430-elf-gdb main.o
  77. msp430-elf-gdb: error while loading shared libraries: libncursesw.so.5: cannot open shared object file: No such file or directory
  78. yay -S ncurses5-compat-libs
  79. ```