📄 9313_finish._c
字号:
//*********************************************************
//测试功能:测试9313放大n+1倍 现在放大2倍
//测试方法:
//测试结果:?
//时钟频率:8m
//管脚分配:Pa0为使能位,Pa1为时序发生位,Pa2为+或-位
//
//注意事项:
//完成时间:2009.03.18
//************************************************
//*************************************************
//头文件
//************************************************
#include <iom16v.h>
#include <macros.h>
//************************************************
//**********************************************************
//函数名称:void DELAY_1US(void)
//参数入口:无
//参数出口:无
//函数功能:延时1us
//注意事项:
//**********************************************************
void DELAY_1US(void)
{
NOP();
}
//**********************************************************
//函数名称:void DELAY_NUS(void)
//参数入口:无
//参数出口:无
//函数功能:延时nus
//注意事项:
//**********************************************************
void DELAY_NUS(unsigned int n)
{
for(;n>0;n--)
DELAY_1US();
}
//**********************************************************
//函数名称:void DELAY_1MS(void)
//参数入口:无
//参数出口:无
//函数功能:延时1ms
//注意事项:i=143*n-2
//**********************************************************
void DELAY_1MS(void)
{
unsigned int i;
for(i=1142;i>0;i--)
;
}
//**********************************************************
//函数名称:void DELAY_1MS(void)
//参数入口:无
//参数出口:无
//函数功能:延时1ms
//注意事项:i=143*n-2
//**********************************************************
void DELAY_NMS(unsigned int n)
{
for(;n>0;n--)
DELAY_1MS();
}
//**********************************************************
//函数名称:void INIT_X9313(void)
//参数入口:无
//参数出口:无
//函数功能:是放大倍数为1
//注意事项:PD0为使能位,PD1为时序发生位,PD2为+或-位
//***************************************************
void PORT_INIT(void)
{
DDRC|=0X07;
PORTC|=0X07;
}
//**********************************************************
//函数名称:void INIT_X9313(void)
//参数入口:无
//参数出口:无
//函数功能:是放大倍数为1
//注意事项:PD0为使能位,PD1为时序发生位,PD2为+或-位
//**********************************************************
void INIT_X9313(void)
{
unsigned char n;
PORTC|=0X07;
//PORTD=(1<<2);//方法倍数减操作
DELAY_NUS(1);
PORTC&=~(1<<0);//使能操作
DELAY_NUS(1);
for(n=35;n>0;n--)
{
PORTC|=(1<<1);//+
DELAY_NUS(2);
PORTC&=~(1<<1);
DELAY_NUS(2);
PORTC|=(1<<1);//+
DELAY_NUS(2);
}
PORTC|=(1<<0);//使能操作
DELAY_NMS(20);
}
//**********************************************************
//函数名称:void X9313_ADD(unsigned char n)
//参数入口:无
//参数出口:无
//函数功能:放大n+1倍
//注意事项:PD0为使能位,PD1为时序发生位,PD2为-时放大
//**********************************************************
void X9313_ADD(unsigned char n)
{
PORTC|=0X07;
PORTC&=~(1<<2);//方法倍数减操作
DELAY_NUS(1);
PORTC&=~(1<<0);//使能操作
DELAY_NUS(1);
for(;n>0;n--)
{
PORTC|=(1<<1);//+
DELAY_NUS(2);
PORTC&=~(1<<1);
DELAY_NUS(2);
PORTC|=(1<<1);//+
DELAY_NUS(2);
}
PORTC|=(1<<0);//使能操作
PORTC|=(1<<2);//方法倍数减操作
//DELAY_NMS(20);
}
//*************************************************
//主函数
//*************************************************
void main(void)
{
PORT_INIT();
INIT_X9313();
X9313_ADD(1);
while(1)
;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -