custom board based on cortex M0 toggle pins not responding.

i am trying to troggle two pins in a custom board built on cortex M0 core( nuvoton nano120 series 120lc2bn)/

i can get to toggle the given pins.

pins are pc0 and pb12.

#include <Device/Nuvoton/NANO1xx/nano1xx.h>

#include "Device/Nuvoton/NANO1xx/system_nano1xx.h"
#include <stdio.h>

int main() {
SystemInit();
//UNLOCKREG();
int i;
//clkintialistaion
CLK->PWRCTL |= CLK_PWRCTL_HXT_EN;
//CLK->PWRCTL |= CLK_PWRCTL_HXT_HF;
CLK->CLKSEL0 |= CLK_CLKSEL0_HCLK_HXT;
CLK->PLLCTL |= CLK_PLLCTL_PLLSRC_HXT;
CLK->PLLCTL |= CLK_PLLCTL_PD;
CLK->CLKDIV0 |= HCLK_CLK_DIVIDER(1);
CLK->CLKSTATUS|= CLK_CLKSTATUS_HXT_STB;
/* Enable system clock source, HIRC and LIRC are default enabled */
UNLOCKREG();
CLK->PWRCTL |= (CLK_PWRCTL_HXT_EN | CLK_PWRCTL_LXT_EN);
LOCKREG();


/* Select HCLK from HIRC */
CLK->CLKDIV0 &= ~CLK_CLKDIV0_HCLK_MASK; /* divider is 0 */
UNLOCKREG();
CLK->CLKSEL0 = (CLK->CLKSEL0 & ~CLK_CLKSEL0_HCLK_MASK) | CLK_CLKSEL0_HCLK_HIRC; /* HCLK = 12MHz */
LOCKREG();

debug_printf("%d\n ",CLK->CLKSTATUS);
//clk enable
CLK->AHBCLK |= CLK_AHBCLK_GPIO_EN;
//pinmux
GCR->PB_H_MFP |= PB12_MFP_GPB12;
GCR->PC_L_MFP |= PC0_MFP_GPC0;

//portconfig
GPIOB->PMD|= GPIO_PMD_PMD0_OUTPUT;
GPIOC->PMD|= GPIO_PMD_PMD12_OUTPUT;
//portsetting
//portsetting
//while(1)
{

//
//GPIOB->DOUT &=0;
//debug_printf("%d",GPIOB->DOUT);
//for(i=0;i<20000;i++);
//for(i=0;i<20000;i++);

GPIOB->DOUT |=(GPIO_DOUT_DOUT_12);
debug_printf("%d\n",GPIOB->DOUT);
for(i=0;i<20000;i++);
for(i=0;i<20000;i++);
//GPIOC->DOUT &=0 ;
for(i=0;i<20000;i++);
for(i=0;i<20000;i++);
debug_printf("%d\n",GPIOC->DOUT);
for(i=0;i<20000;i++);
GPIOC->DOUT |=(GPIO_DOUT_DOUT_0 );
//GPIOB->|=1;
//delay
//for(i=0;i<20000;i++);
//
//GPIOB->DOUT |=0;
//GPIOC->DOUT |=0;
}

debug_printf("hello world\n");

//SYS_UnlockReg();
LOCKREG();
return 0;

}

I  cant get the output.

Parents Reply Children
No data
More questions in this forum