这是我写的程序,但是这里显示找不到库函数。后来我在网上找了答案,有人说库函数写进了核心文件里,但是我在主函数文件里编译了核心文件还是不行。如果我要用这种库函数的形式写应该怎么做?
#include"stm32f10x.h"
#include"core_cm3.h"
#define unsigned char uchar
void RCC_Configuration()
{
ErrorStatus a;
RCC_HSEConfig(RCC_HSE_ON);
a=RCC_WaitForHSEStartUp();
if(a==SUCCESS);
{
RCC_HCLKConfig(RCC_SYSCLK_Div1);
RCC_PCLK1Config(RCC_HCLK_Div2);
RCC_PCLK2Config(RCC_HCLK_Div1);
FLASH_SetLatency(FLASH_Latency_2);
FLASH_PrefetchBufferCmd(FLASH_PrefetchBuffer_Enable);
RCC_PLLConfig(RCC_PLLSource_HSE_Div1,RCC_PLLMul_9);
RCC_PLLCmd(ENABLE);
while(RCC_GetFlagStatus(RCC_FLAG_PLLRDY)==RESET);
RCC_SYSCLKConfig(RCC_SYSCLKSource_PLLCLK);
while(RCC_GetSYSCLKSource()!=0x08);
}
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB,ENABLE);
}
void GPIO_Configuration()
{
GPIO_InitTypeDef a;
a.GPIO_Pin=GPIO_Pin_All;
a.GPIO_Speed=GPIO_Speed_50MHz;
a.GPIO_Mode=GPIO_Mode_Out_PP;
GPIO_Init(GPIOB,&a);
}
void SysTick_Configuration()
{
SysTick_CounterCmd(SysTick_Counter_Disable);
SysTick_CLKSource(SysTick_HCLK_Div8);
SysTick_CounterCmd(SysTick_Counter_Clear);
SysTick_SetReload(9000000);
}
void Dealy_StsTick(uhar delay)
{
uchar i;
for(i=0;i<delay;i++)
{
SysTick_CounterCmd(SysTick_Counter_Enable);
while(SysTick_GteFlagStatus(SysTick_FLAGG_COUNT)==0);
SysTick_CounterCmd(SysTick_Counter_Disable);
SysTick_CounterCmd(SysTick_Counter_Clear);
}
}
int main(void)
{
RCC_Configuration();
GPIO_Configuration();
while(1)
{
GPIO_WriteBits(GPIOB,GPIO_Pin_0,(BitAction)1-ReadOutputDataBit(GPIOB,GPIO_Pin_0));//¶ÁÈ¡µ±Ç°¶Ë¿ÚÖ¸£¬È»ºóÈ¡·´.
Delay_SysTick(1);
}
}
然后就报错了。
compiling main.c...
..Usermain.c(34): warning: #223-D: function "SysTick_CounterCmd" declared implicitly
..Usermain.c(34): error: #20: identifier "SysTick_Counter_Disable" is undefined
..Usermain.c(35): warning: #223-D: function "SysTick_CLKSource" declared implicitly
..Usermain.c(35): error: #20: identifier "SysTick_HCLK_Div8" is undefined
..Usermain.c(36): error: #20: identifier "SysTick_Counter_Clear" is undefined
..Usermain.c(37): warning: #223-D: function "SysTick_SetReload" declared implicitly
..Usermain.c(39): error: #20: identifier "uhar" is undefined
..Usermain.c(41): error: #20: identifier "uchar" is undefined
..Usermain.c(44): warning: #223-D: function "SysTick_CounterCmd" declared implicitly
..Usermain.c(44): error: #20: identifier "SysTick_Counter_Enable" is undefined
..Usermain.c(45): warning: #223-D: function "SysTick_GteFlagStatus" declared implicitly
..Usermain.c(45): error: #20: identifier "SysTick_FLAGG_COUNT" is undefined
..Usermain.c(46): error: #20: identifier "SysTick_Counter_Disable" is undefined
..Usermain.c(47): error: #20: identifier "SysTick_Counter_Clear" is undefined
..Usermain.c(56): warning: #223-D: function "GPIO_WriteBits" declared implicitly
..Usermain.c(56): warning: #223-D: function "ReadOutputDataBit" declared implicitly
..Usermain.c(57): warning: #223-D: function "Delay_SysTick" declared implicitly
Target not created
后来我又试着自己写了一个操作寄存器的程序(只有延时函数写的寄存器),但写完后他提示我说找不到寄存器名的定义。然后我就彻底不知道怎么办了。
#include"stm32f10x.h"
void SysTick_Init()
{
SyaTick_>CTRL&=0xffff^0x0001<<0;
SysTick_>CTRL&=0xffff^0x0001<<2;
}
void Delay_ms(u32 b)
{
while(b*900>0xffffff);
SysTick_>VAL=0;
SysTick_>LOAD=b*900;
SysTick_>CTRL|=1 ;
while(SysTick_>CTRL&0x7fff==0);
SyaTick_>CTRL&=0xffff^0x0001<<0;
}
void Delay_us(u32 b)
{
while(b*9>0xffffff);
SysTick_>VAL=0;
SysTick_>LOAD=b*9;
SysTick_>CTRL|=1;
while(SysTick_>CTRL&0x7fff==0);
SyaTick_>CTRL&=0xffff^0x0001<<0;
}
..SYSTEMDelaydelay.c(4): error: #20: identifier "SyaTick_" is undefined
..SYSTEMDelaydelay.c(4): error: #20: identifier "CTRL" is undefined
..SYSTEMDelaydelay.c(5): error: #20: identifier "SysTick_" is undefined
..SYSTEMDelaydelay.c(10): error: #20: identifier "SysTick_" is undefined
..SYSTEMDelaydelay.c(10): error: #20: identifier "VAL" is undefined
..SYSTEMDelaydelay.c(11): error: #20: identifier "LOAD" is undefined
..SYSTEMDelaydelay.c(12): error: #20: identifier "CTRL" is undefined
..SYSTEMDelaydelay.c(14): error: #20: identifier "SyaTick_" is undefined
..SYSTEMDelaydelay.c(19): error: #20: identifier "SysTick_" is undefined
..SYSTEMDelaydelay.c(19): error: #20: identifier "VAL" is undefined
..SYSTEMDelaydelay.c(20): error: #20: identifier "LOAD" is undefined
..SYSTEMDelaydelay.c(21): error: #20: identifier "CTRL" is undefined
..SYSTEMDelaydelay.c(23): error: #20: identifier "SyaTick_" is undefined
我没有用视屏中的那个SYSTEM文件夹里的程序,想自己写。请各路大神告诉我解决方法~~最好是寄存器和库函数的方法都说一下。谢谢
此帖出自
小平头技术问答
一周热门 更多>