Merhaba, Nuvotona yeni başladım ve bir projemde m031fc1ae işlemcisini kullandım, başlıkta yazdığım gibi bir problem yaşıyorum sebebi nedir?
Yazılımda butona basıldığında ledin yan sön yapması gerekiyor fakat devreye enerji verdiğim gibi devre sürekli ledi yakıp söndürüyor. Butonlarda pulldown dirençi mevcut ve NuTool-PinView uygulaması ile izlediğim zaman butonların bağlı olduğu pinler low olarak gözüküyor bastığımda high konumuna geçiyorlar.
SYS_Init fonksiyonunu nuvotonun programı ile oluşturdum.
Yazılımda butona basıldığında ledin yan sön yapması gerekiyor fakat devreye enerji verdiğim gibi devre sürekli ledi yakıp söndürüyor. Butonlarda pulldown dirençi mevcut ve NuTool-PinView uygulaması ile izlediğim zaman butonların bağlı olduğu pinler low olarak gözüküyor bastığımda high konumuna geçiyorlar.
SYS_Init fonksiyonunu nuvotonun programı ile oluşturdum.
#include "stdio.h"
#include "NuMicro.h"
volatile unsigned int usTimer;
void SYS_Init(void);
void usDelay(unsigned int us);
#define LED_HIGH PB14=1
#define LED_LOW PB14=0
int32_t main(void)
{
/* Init System, IP clock and multi-function I/O. */
SYS_Init();
GPIO_SetMode(PF, BIT2, GPIO_MODE_OUTPUT);//LED1
GPIO_SetMode(PF, BIT3, GPIO_MODE_OUTPUT);//LED2
GPIO_SetMode(PB, BIT14, GPIO_MODE_OUTPUT);//LED3
GPIO_SetMode(PB, BIT2, GPIO_MODE_INPUT);//BTN
GPIO_SetMode(PB, BIT4, GPIO_MODE_INPUT);//BTN
GPIO_SetMode(PB, BIT5, GPIO_MODE_INPUT);//BTN
GPIO_SetMode(PB, BIT13, GPIO_MODE_INPUT);//BTN
usDelay(90000);
usDelay(90000);
usDelay(90000);
while(1)
{
if(PB2)
{
LED_HIGH;
usDelay(90000);
LED_LOW;
usDelay(90000);
}
}
}
void SYS_Init(void)
{
/* Unlock protected registers */
SYS_UnlockReg();
/* Enable clock source */
CLK_EnableXtalRC(CLK_PWRCTL_HIRCEN_Msk);
/* Waiting for clock source ready */
CLK_WaitClockReady(CLK_STATUS_HIRCSTB_Msk);
/* If the defines do not exist in your project, please refer to the related clk.h in the Header folder appended to the tool package. */
/* Set HCLK clock */
CLK_SetHCLK(CLK_CLKSEL0_HCLKSEL_HIRC, CLK_CLKDIV0_HCLK(3));
/* Set PCLK-related clock */
CLK->PCLKDIV = (CLK_PCLKDIV_APB0DIV_DIV1 | CLK_PCLKDIV_APB1DIV_DIV1);
/* Enable IP clock */
CLK_EnableModuleClock(TMR0_MODULE);
/* Set IP clock */
CLK_SetModuleClock(TMR0_MODULE, CLK_CLKSEL1_TMR0SEL_HIRC, MODULE_NoMsk);
/* Update System Core Clock */
/* User can use SystemCoreClockUpdate() to calculate SystemCoreClock. */
SystemCoreClockUpdate();
/* Lock protected registers */
SYS_LockReg();
}
void usDelay(unsigned int us)
{
TIMER_Delay(TIMER0, us);
}
Moderatör tarafında düzenlendi:


