Blog‎ > ‎

Template for C Programs on NUC131 Device

posted Nov 6, 2017, 6:15 PM by MUHAMMAD MUN`IM AHMAD ZABIDI   [ updated Nov 6, 2017, 6:16 PM ]
Below is template for NUC131. UART is always used to debug/print. Seems like semihosting is default. We need to add 'semihosting' in the notes somehow.

#include <stdio.h>
#include "NUC131.h"

void SYS_Init(void)
{
  SYS_UnlockReg();
  CLK->APBCLK = CLK_APBCLK_UART0_EN_Msk;
  SystemCoreClockUpdate();
  SYS->GPB_MFP = SYS_GPB_MFP_PB0_UART0_RXD | SYS_GPB_MFP_PB1_UART0_TXD;
  SYS_LockReg();
}


int main()
{
  int8_t ch;

  SYS_Init();
  UART_Open(UART0, 115200);

  printf("Simple Demo Code\n\n");
  printf("Please Input Any Key\n\n");
  do {
    printf("Input: ");
    ch = getchar();
    printf("%c\n", ch);
  }  while(1);
}
Comments