程序是,根据16个IO的高低电平决定一个变量的值,但是我在主函数用串口打印出来的值一直显示是0,有人遇到多这样情况吗?下面是程序。。。管脚的定义:
#define TALLY_1 PBin(0)
#define TALLY_2 PBin(1)
#define TALLY_3 PBin(3)
#define TALLY_4 PBin(4)
#define TALLY_5 PBin(8)
#define TALLY_6 PBin(10)
#define TALLY_7 PBin(11)
#define TALLY_8 PBin(12)
#define TALLY_9 PBin(13)
#define TALLY_10 PBin(15)
#define TALLY_11 PCin(13)
#define TALLY_12 PCin(14)
#define TALLY_13 PCin(15)
#define TALLY_14 PAin(0)
#define TALLY_15 PAin(1)
#define TALLY_16 PAin(15)
变化的函数:
u8 Tally_Control()
{
#ifdef RX_CRAD
static u8 tally_data;
if(TALLY_1)
tally_data=1;
if(TALLY_2)
tally_data=2;
if(TALLY_3)
tally_data=3;
if(TALLY_4)
tally_data=4;
if(TALLY_5)
tally_data=5;
if(TALLY_6)
tally_data=6;
if(TALLY_7)
tally_data=7;
if(TALLY_8)
tally_data=8;
if(TALLY_9)
tally_data=9;
if(TALLY_10)
tally_data=10;
if(TALLY_11)
tally_data=11;
if(TALLY_12)
tally_data=12;
if(TALLY_13)
tally_data=13;
if(TALLY_14)
tally_data=14;
if(TALLY_15)
tally_data=15;
if(TALLY_16)
tally_data=16;
return tally_data;
#endif
}
主函数:
int main(void)
{
u8 t=0;
NVIC_Configuration();
delay_init();
uart_init(115200);
NRF24L01_Init();
LED_Init();
KEY_Init();
Get_addr();
RF_Init();
printf("RF_Init()
");
RF_send_data( );
//RX_Mode();
while(1)
{
if(KEY0==0)
{
while(KEY0==0);
TalkRegister();
}
if(USART_RX_STA&0x8000)
{
USART_RX_STA =0;
Tally_send(USART_RX_BUF[0]);
}
Tally_send(Tally_Control());
printf("tally_control %d
",Tally_Control());
//Tally_send(1);
delay_ms(100);
}
}
串口打印出来的结果
有人知道该怎么做吗?
请指教
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
Tally_Control()不用看了,你的配置有问题,下面的定义是实现读IO的输入状态或者是读IO输出状态,具体要看代码怎么配置,就下面的定义看不出来#define TALLY_1 PBin(0)
#define TALLY_2 PBin(1)
#define TALLY_3 PBin(3)
#define TALLY_4 PBin(4)
#define TALLY_5 PBin(8)
#define TALLY_6 PBin(10)
#define TALLY_7 PBin(11)
#define TALLY_8 PBin(12)
#define TALLY_9 PBin(13)
#define TALLY_10 PBin(15)
#define TALLY_11 PCin(13)
#define TALLY_12 PCin(14)
#define TALLY_13 PCin(15)
#define TALLY_14 PAin(0)
#define TALLY_15 PAin(1)
#define TALLY_16 PAin(15)
配置有问题?我在另外一个地方已经初始化IO口啦,这是用宏定义代替这个IO口啊
我MCU外一个元器件,会改变IO口的状态啊
一周热门 更多>