新手上路
- 积分
- 35
- 金钱
- 35
- 注册时间
- 2014-4-21
- 在线时间
- 0 小时
|
楼主 |
发表于 2014-4-25 00:58:25
|
显示全部楼层
回复【6楼】 正点原子 :<br />
---------------------------------<br />
#include "led.h" <br />
#include "delay.h" <br />
#include "sys.h" <br />
#include "key.h" <br />
#include "usart.h" <br />
#include "lcd.h" <br />
#include "spi.h" <br />
#include "flash.h" <br />
#include "24l01.h" <br />
#include "ds18b20.h" <br />
#include "data_transfer.h" <br />
<br />
<br />
<br />
short temp = 0; <br />
<br />
<br />
<br />
void Check_bsp(){ <br />
<br />
while(NRF24L01_Check())//检测NRF <br />
{ <br />
LCD_ShowString(60,110,"NRF Check Failed!"); <br />
delay_ms(500); <br />
LCD_ShowString(60,110,"lease Check! "); <br />
delay_ms(500); <br />
LED0=!LED0;//DS0闪烁 <br />
} <br />
LCD_ShowString(60,110,"NRF Ready! "); <br />
POINT_COLOR=RED;//设置字体为蓝色 <br />
<br />
//RX_Mode(); <br />
TX_Mode(); <br />
NRF_Mode(MODEL_TX2,40); <br />
<br />
while(DS18B20_Init())//初始化DS18B20,兼检测18B20 <br />
{ <br />
LCD_ShowString(60,130,"DS18B20 Check Failed!"); <br />
delay_ms(500); <br />
LCD_ShowString(60,130,"lease Check! "); <br />
delay_ms(500); <br />
LED0=!LED0;//DS0闪烁 <br />
} <br />
LCD_ShowString(60,130,"DS18B20 Ready! "); <br />
POINT_COLOR=BLUE;//设置字体为蓝色 <br />
LCD_ShowString(60,150, "Temperate: . C"); <br />
<br />
} <br />
<br />
void Init(){ <br />
<br />
SystemInit(); //系统时钟设置 <br />
delay_init(72); //延时初始化 <br />
NVIC_Configuration(); <br />
uart_init(9600);//串口1初始化 <br />
LED_Init();//LED初始化 <br />
// KEY_Init(); <br />
NRF24L01_Init(); <br />
NRF_Mode(MODEL_TX,40); <br />
<br />
<br />
<br />
LCD_Init();//初始化液晶 <br />
<br />
POINT_COLOR=RED;//设置字体为红色 <br />
LCD_ShowString(60,50,"Mini STM32"); <br />
LCD_ShowString(60,70,"WD_NRF "); <br />
<br />
LCD_ShowString(60,90,"2014/1/1"); <br />
<br />
} <br />
<br />
void Display_Temp(){ <br />
<br />
<br />
if(temp<0) <br />
{ <br />
temp=-temp; <br />
LCD_ShowChar(140,150,'-',16,0);//显示负号 <br />
} <br />
LCD_ShowNum(148,150,temp/10,2,16);//显示温度值 <br />
LCD_ShowNum(172,150,temp%10,1,16);//显示温度值 <br />
printf("t1:%d\n",temp); <br />
delay_ms(200); <br />
LED0=!LED0; <br />
<br />
} <br />
<br />
<br />
int main(void) <br />
{ <br />
<br />
/**/ <br />
Init(); <br />
<br />
Check_bsp(); <br />
<br />
while(1) <br />
{ <br />
<br />
temp=DS18B20_Get_Temp(); <br />
<br />
Send_Temp(); <br />
NRF_Check_Event(); <br />
<br />
Display_Temp(); <br />
<br />
} <br />
} <br />
请问这程序为何检测不到ds18b20呢?怎么改 |
|