This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

LP-MSPM0G3507: First code to test build environment on MSPM0G3507 Launch Pad

Part Number: LP-MSPM0G3507
Other Parts Discussed in Thread: MSPM0G3507

OK on my new MSPM0G3507 launch pad, and just setting up my build environment. So first program to flash the LED, is simple:

#include "ti_msp_dl_config.h"
#include "ti/devices/msp/m0p/mspm0g350x.h"
#include "ti/devices/msp/peripherals/hw_gpio.h"


int main(void) {
  GPIO_Regs *GPIOA=(GPIO_Regs *)GPIOA_BASE; // set up point to GPIO A

  GPIOA->DOE31_0 |= 1; // enable PA0
  
  while (1) {
    for (int i=0; i<100000; i++); // pause
    GPIOA->DOUT31_0 ^= 1; // toggle PA0
  }
}

Quick look with objdump -x and the compiled code looks like it has set up correct interrupts etc

arm-none-eabi-objdump -x gcc/pwm_led_driver.out 

gcc/pwm_led_driver.out:     file format elf32-littlearm
gcc/pwm_led_driver.out
architecture: armv6s-m, flags 0x00000112:
EXEC_P, HAS_SYMS, D_PAGED
start address 0x000000c0

Program Header:
    LOAD off    0x00001000 vaddr 0x00000000 paddr 0x00000000 align 2**12
         filesz 0x000001b8 memsz 0x000001b8 flags r-x
    LOAD off    0x00002000 vaddr 0x20200000 paddr 0x000001b8 align 2**12
         filesz 0x00000000 memsz 0x00000000 flags rw-
    LOAD off    0x00000000 vaddr 0x20200000 paddr 0x20200000 align 2**12
         filesz 0x00000000 memsz 0x00000000 flags rw-
private flags = 0x5000200: [Version5 EABI] [soft-float ABI]

Sections:
Idx Name          Size      VMA       LMA       File off  Algn
  0 .intvecs      000000c0  00000000  00000000  00001000  2**2
                  CONTENTS, ALLOC, LOAD, READONLY, DATA
  1 .text         000000f8  000000c0  000000c0  000010c0  2**2
                  CONTENTS, ALLOC, LOAD, READONLY, CODE
  2 .ramfunc      00000000  20200000  20200000  00002000  2**0
                  CONTENTS
  3 .rodata       00000000  000001b8  000001b8  00002000  2**0
                  CONTENTS, ALLOC, LOAD, DATA
  4 .ARM.extab    00000000  000001b8  000001b8  00002000  2**0
                  CONTENTS
  5 .data         00000000  20200000  000001b8  00002000  2**0
                  CONTENTS, ALLOC, LOAD, DATA
  6 .bss          00000000  20200000  000001b8  00002000  2**0
                  ALLOC
  7 .debug_info   0001c956  00000000  00000000  00002000  2**0
                  CONTENTS, READONLY, DEBUGGING, OCTETS
  8 .debug_abbrev 00000bb8  00000000  00000000  0001e956  2**0
                  CONTENTS, READONLY, DEBUGGING, OCTETS
  9 .debug_aranges 00000268  00000000  00000000  0001f50e  2**0
                  CONTENTS, READONLY, DEBUGGING, OCTETS
 10 .debug_rnglists 000000b8  00000000  00000000  0001f776  2**0
                  CONTENTS, READONLY, DEBUGGING, OCTETS
 11 .debug_line   00002b9d  00000000  00000000  0001f82e  2**0
                  CONTENTS, READONLY, DEBUGGING, OCTETS
 12 .debug_str    00003b1f  00000000  00000000  000223cb  2**0
                  CONTENTS, READONLY, DEBUGGING, OCTETS
 13 .comment      00000097  00000000  00000000  00025eea  2**0
                  CONTENTS, READONLY
 14 .ARM.attributes 0000002c  00000000  00000000  00025f81  2**0
                  CONTENTS, READONLY
 15 .debug_frame  00000670  00000000  00000000  00025fb0  2**2
                  CONTENTS, READONLY, DEBUGGING, OCTETS
 16 .debug_ranges 00000688  00000000  00000000  00026620  2**0
                  CONTENTS, READONLY, DEBUGGING, OCTETS
 17 .debug_loc    000023d6  00000000  00000000  00026ca8  2**0
                  CONTENTS, READONLY, DEBUGGING, OCTETS
SYMBOL TABLE:
00000000 l    d  .intvecs	00000000 .intvecs
000000c0 l    d  .text	00000000 .text
20200000 l    d  .ramfunc	00000000 .ramfunc
000001b8 l    d  .rodata	00000000 .rodata
000001b8 l    d  .ARM.extab	00000000 .ARM.extab
20200000 l    d  .data	00000000 .data
20200000 l    d  .bss	00000000 .bss
00000000 l    d  .debug_info	00000000 .debug_info
00000000 l    d  .debug_abbrev	00000000 .debug_abbrev
00000000 l    d  .debug_aranges	00000000 .debug_aranges
00000000 l    d  .debug_rnglists	00000000 .debug_rnglists
00000000 l    d  .debug_line	00000000 .debug_line
00000000 l    d  .debug_str	00000000 .debug_str
00000000 l    d  .comment	00000000 .comment
00000000 l    d  .ARM.attributes	00000000 .ARM.attributes
00000000 l    d  .debug_frame	00000000 .debug_frame
00000000 l    d  .debug_ranges	00000000 .debug_ranges
00000000 l    d  .debug_loc	00000000 .debug_loc
00000000 l    df *ABS*	00000000 startup_mspm0g3507_gcc.c
00000000 l    df *ABS*	00000000 pwm_led_driver.c
00000000 l    df *ABS*	00000000 ti_msp_dl_config.c
00000000 l    df *ABS*	00000000 dl_common.c
00000000 l    df *ABS*	00000000 dl_timer.c
000001ac  w    F .text	00000008 TIMG6_IRQHandler
000001ac  w    F .text	00000008 TIMG8_IRQHandler
20200000 g       .data	00000000 __data_start__
000001ac  w    F .text	00000008 I2C0_IRQHandler
000001ac  w    F .text	00000008 HardFault_Handler
00000080 g       *ABS*	00000000 _Min_Stack_Size
000001ac  w    F .text	00000008 SysTick_Handler
000001ac  w    F .text	00000008 PendSV_Handler
000001ac  w    F .text	00000008 NMI_Handler
000001b8 g       .ARM.extab	00000000 __exidx_end
000001ac  w    F .text	00000008 I2C1_IRQHandler
000001ac  w    F .text	00000008 UART1_IRQHandler
000001b8 g       .text	00000000 __etext
000001ac  w    F .text	00000008 TIMA1_IRQHandler
20200000 g       *ABS*	00000000 _vtable_base_address
000001ac  w    F .text	00000008 UART0_IRQHandler
000001ac  w    F .text	00000008 ADC0_IRQHandler
20200000 g       .debug_info	00000000 __HeapLimit
20200000 g       .debug_info	00000000 __heap_end__
20200000 g       .bss	00000000 __bss_start__
000001ac  w    F .text	00000008 SPI1_IRQHandler
000001b8 g       .ARM.extab	00000000 __exidx_start
000001ac  w    F .text	00000008 TIMG0_IRQHandler
000001ac  w    F .text	00000008 ADC1_IRQHandler
000001ac  w    F .text	00000008 GROUP1_IRQHandler
000001ac  w    F .text	00000008 RTC_IRQHandler
00000114  w    F .text	00000098 Reset_Handler
000001ac  w    F .text	00000008 GROUP0_IRQHandler
20200000 g       .debug_info	00000000 end
000001ac  w    F .text	00000008 UART2_IRQHandler
20200000 g       .data	00000000 __data_end__
20200000 g       .bss	00000000 __bss_end__
00000000 g       *ABS*	00000000 _Min_Heap_Size
000001ac g     F .text	00000008 Default_Handler
20200000 g       .debug_info	00000000 __end
000001b8 g       *ABS*	00000000 __data_load__
000000c0 g     F .text	00000054 main
000001b8 g       *ABS*	00000000 __ramfunct_load__
000001ac  w    F .text	00000008 SVC_Handler
000001b8 g       .text	00000000 __init_array_end
20200000 g       .debug_info	00000000 __heap_start__
000001ac  w    F .text	00000008 TIMG12_IRQHandler
20200000 g       .ramfunc	00000000 __ramfunct_end__
000001ac  w    F .text	00000008 DAC0_IRQHandler
20208000 g       .bss	00000000 __StackTop
000001ac  w    F .text	00000008 TIMG7_IRQHandler
000001ac  w    F .text	00000008 SPI0_IRQHandler
20200000 g       .ramfunc	00000000 __ramfunct_start__
20200000 g       .debug_info	00000000 _end
000001ac  w    F .text	00000008 AES_IRQHandler
00000000 g     O .intvecs	000000c0 interruptVectors
000001ac  w    F .text	00000008 DMA_IRQHandler
000001b8 g       .text	00000000 __init_array_start
000001ac  w    F .text	00000008 TIMA0_IRQHandler
20200000 g       .debug_info	00000000 _stack
000001ac  w    F .text	00000008 UART3_IRQHandler
00000000 g       *ABS*	00000000 _intvecs_base_address
000001ac  w    F .text	00000008 CANFD0_IRQHandler

But led doesn't flash, and trying |= 1 and &= ~1 (e.g. on and off) also don't work. So as usual I must be doing something simple wrong! Anyone any ideas?

  • I'm pretty sure you also need to set the IOMUX pad with something like:

    >  IOMUX->SECCFG.PINCM[1] = (IOMUX_PINCM_PC_CONNECTED | ((uint32_t) 0x00000001));

    where [1] refers to PA0 per data sheet (SLASEX6A) Table 6-1 and PF=1 is ("well known") GPIO function. (My Launchpad just broke, so I can't try it myself.)

    [Edit :Minor clarification]

  • Hi David,

    Bruce is correct,  the IOMUX has to be configured as well.

    I think the index needs to be decremented by one though to reflect the 0 indexing used in the header files (see below snippet from mspm0g350x.h, IOMUX_PINCM1 is actually defined as 0 rather than 1). 

    So that line Bruce shared should be:

    IOMUX->SECCFG.PINCM[0] = (IOMUX_PINCM_PC_CONNECTED | ((uint32_t) 0x00000001));

    You could of course just use IOMUX_PINCM1 as well. 

    You will also need to enable power to the GPIO peripheral. You should do this first in your code before modifying any of the GPIOA registers. 

    GPIOA->GPRCM.PWREN = (GPIO_PWREN_KEY_UNLOCK_W | GPIO_PWREN_ENABLE_ENABLE);
    delay_cycles(16);

    See this section from the Technical Reference Manual (SLAU846) for more details.

    Best Regards,
    Brandon Fisher

  • Thanks both - yes that solved the problem. Last night reading the TRM I realised I need to set IOMUX. reading the data sheet, I didn't find Table 6-1 until you pointed me to it!

    Liked the comment "PF=1 is the "well known" GPIO function" - yes, I couldn't find it written anywhere that PF=1; it gavce other PF values though.

    Brandon was right on using [0] - but it isn't metioned in my mspm0g350x.h - I'm still on the original mspmp_sdk_1_00_00_04 - I'll check the latest.

    Bruce - how did you break you launchpad?

    Anyway my current code- that does flash led, and I've commented out code that not needed!

    #include "ti_msp_dl_config.h"
    #include "ti/devices/msp/m0p/mspm0g350x.h"
    // #include "ti/devices/msp/peripherals/hw_gpio.h"
    // #include "ti/devices/msp/peripherals/hw_iomux.h"
    
    
    int main(void) {
      //  static GPIO_Regs *GPIOA=(GPIO_Regs *)GPIOA_BASE; // set up point to GPIO A
      //  static IOMUX_REG *IOMUX=(IOMUX_Regs *)IOMUX_BASE; // set up point to IOMUX
    
      GPIOA->GPRCM.PWREN = (GPIO_PWREN_KEY_UNLOCK_W | GPIO_PWREN_ENABLE_ENABLE);
      delay_cycles(16);
    
      IOMUX->SECCFG.PINCM[0] = (uint32_t) (IOMUX_PINCM_PC_CONNECTED | 1);
      GPIOA->DOE31_0 |= 1; // enable PA0
      
      while (1) {
        for (uint32_t i=0; i<10000000; i++) {
          asm ("nop");
        } // pause
        GPIOA->DOUT31_0 ^= 1; // toggle PA0
      }
    }

**Attention** This is a public forum