We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
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;//clkintialistaionCLK->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 enableCLK->AHBCLK |= CLK_AHBCLK_GPIO_EN; //pinmuxGCR->PB_H_MFP |= PB12_MFP_GPB12; GCR->PC_L_MFP |= PC0_MFP_GPC0;
//portconfigGPIOB->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.