中级会员
- 积分
- 207
- 金钱
- 207
- 注册时间
- 2013-7-25
- 在线时间
- 0 小时
|
5金钱
我想要完成的功能是:两块32板,一块用OV7670采集图像,用24L01发送图像数据;另一块用24L01采集图像,用TFT屏显示出来。<br />
<br />
可是结果却是:发送板停在<span style="font-size:14px;line-height:1.5;">"NRF24L01 OK"不动了。接收板也停在</span><span style="font-size:14px;line-height:1.5;">"NRF24L01 OK"</span><span style="font-size:14px;line-height:1.5;">也不动了。<br />
我怎么也想不通是哪里出现问题。猜想是无线模块的同步有问题,可是按逻辑应该是没有错误的呀。怎么也不可能出现这样的结果</span><span style="font-size:14px;line-height:1.5;"><br />
</span><span style="font-size:14px;line-height:1.5;"></span><br />
<br />
这是我发送代码<br />
<div style="background-color:#E8E8E8;">
[mw_shl_code=c,true]#include "sys.h"
#include "usart.h"
#include "delay.h"
#include "led.h"
#include "beep.h"
#include "key.h"
#include "exti.h"
#include "wdg.h"
#include "timer.h"
#include "tpad.h"
#include "oled.h"
#include "lcd.h"
#include "usmart.h"
#include "rtc.h"
#include "wkup.h"
#include "adc.h"
#include "dac.h"
#include "dma.h"
#include "24cxx.h"
#include "flash.h"
#include "rs485.h"
#include "can.h"
#include "touch.h"
#include "remote.h"
#include "joypad.h"
#include "adxl345.h"
#include "ds18b20.h"
#include "dht11.h"
#include "24l01.h"
#include "mouse.h"
#include "stmflash.h"
#include "rda5820.h"
#include "audiosel.h"
#include "ov7670.h"
const u8*LMODE_TBL[5]={"Auto","Sunny","Cloudy","Office","Home"}; //5种光照模式
const u8*EFFECTS_TBL[7]={"Normal","Negative","B&W","Redish","Greenish","Bluish","Antique"}; //7种特效
extern u8 ov_sta; //在exit.c里面定义
//更新LCD显示
void camera_refresh(void)
{
u32 j;
u16 color;
u32 sendCount=0;
u8 tmp_buf[32];
NRF24L01_TX_Mode();
if(ov_sta==2)
{
LCD_Scan_Dir(U2D_L2R); //从上到下,从左到右
LCD_SetCursor(0x00,0x0000); //设置光标位置
LCD_WriteRAM_Prepare(); //开始写入GRAM
OV7670_RRST=0; //开始复位读指针
OV7670_RCK=0;
OV7670_RCK=1;
OV7670_RCK=0;
OV7670_RRST=1; //复位读指针结束
OV7670_RCK=1;
for(j=0;j<76800;j++)
{
OV7670_RCK=0;
color=GPIOC->IDR&0XFF; //读数据
tmp_buf[sendCount++]=GPIOC->IDR&0XFF;
OV7670_RCK=1;
color<<=8;
OV7670_RCK=0;
color|=GPIOC->IDR&0XFF; //读数据
tmp_buf[sendCount++]=GPIOC->IDR&0XFF;
OV7670_RCK=1;
LCD->LCD_RAM=color;
if(sendCount>=32){
sendCount=0;
while(NRF24L01_TxPacket(tmp_buf)!=TX_OK); //等待数据发送完毕
}
}
EXTI->R=1<<8; //清除LINE8上的中断标志位
ov_sta=0; //开始下一次采集
NRF24L01_RX_Mode(); //配置为接收模式
while(NRF24L01_RxPacket(tmp_buf)!=0); //等待同步信号
}
}
int main(void)
{
u32 count;
u8 SendCount=0;
u8 tmp_buf[32];
Stm32_Clock_Init(9); //系统时钟设置
uart_init(72,9600); //串口初始化为9600
delay_init(72); //延时初始化
usmart_dev.init(72); //初始化US
LCD_Init(); //初始化LCD
NRF24L01_Init(); //初始化NRF24L01
OV7670_Init();
POINT_COLOR=RED;//设置字体为红色
LCD_ShowString(60,50,200,16,16,"WarShip STM32");
LCD_ShowString(60,70,200,16,16,"OV7670 TEST");
LCD_ShowString(60,90,200,16,16,"ATOM@ALIENTEK");
LCD_ShowString(60,110,200,16,16,"2012/9/14");
LCD_ShowString(60,130,200,16,16,"KEY0ight Mode");
LCD_ShowString(60,150,200,16,16,"KEY1:Saturation");
LCD_ShowString(60,170,200,16,16,"KEY2:Brightness");
LCD_ShowString(60,190,200,16,16,"KEY_UP:Contrast");
LCD_ShowString(60,210,200,16,16,"TPAD:Effects");
LCD_ShowString(60,230,200,16,16,"OV7670 Init...");
while(OV7670_Init())//初始化OV7670
{
LCD_ShowString(60,230,200,16,16,"OV7670 Error!!");
delay_ms(200);
LCD_Fill(60,230,239,246,WHITE);
delay_ms(200);
}
LCD_ShowString(60,230,200,16,16,"OV7670 Init OK");
delay_ms(1500);
LCD_Clear(WHITE);
while(NRF24L01_Check()) //检查NRF24L01是否在位.
{
LCD_ShowString(60,130,200,16,16,"NRF24L01 Error");
delay_ms(200);
LCD_Fill(60,130,239,130+16,WHITE);
delay_ms(200);
}
LCD_ShowString(60,130,200,16,16,"NRF24L01 OK");
EXTI8_Init(); //使能定时器捕获帧同步信号
OV7670_Window_Set(10,174,240,320); //设置窗口
OV7670_CS=0;
NRF24L01_RX_Mode();//配置为接收模式
while(NRF24L01_RxPacket(tmp_buf)!=0); //等待同步信号
while(1)
{
camera_refresh();//更新显示
}
}
[/mw_shl_code]
</div>
<br />
<br />
<br />
这是我接收代码<br />
<div style="background-color:#E8E8E8;">
[mw_shl_code=c,true]#include "sys.h"
#include "usart.h"
#include "delay.h"
#include "led.h"
#include "beep.h"
#include "key.h"
#include "exti.h"
#include "wdg.h"
#include "timer.h"
#include "tpad.h"
#include "oled.h"
#include "lcd.h"
#include "usmart.h"
#include "rtc.h"
#include "wkup.h"
#include "adc.h"
#include "dac.h"
#include "dma.h"
#include "24cxx.h"
#include "flash.h"
#include "rs485.h"
#include "can.h"
#include "touch.h"
#include "remote.h"
#include "joypad.h"
#include "adxl345.h"
#include "ds18b20.h"
#include "dht11.h"
#include "24l01.h"
#include "mouse.h"
#include "stmflash.h"
#include "rda5820.h"
#include "audiosel.h"
#include "ov7670.h"
#include "sram.h"
#include "malloc.h"
#include "string.h"
int main(void)
{
u32 count=0;
u32 receivecount=0; //记录接收到的数据,当其大于320*240*2时重置为0
u32 ReceiveCount=0;
u8* showbuf;
u8* a;
u16 color;
Stm32_Clock_Init(9); //系统时钟设置
uart_init(72,9600); //串口初始化为9600
delay_init(72); //延时初始化
LCD_Init(); //初始化LCD
usmart_dev.init(72); //初始化USMART
NRF24L01_Init(); //初始化无线模块
FSMC_SRAM_Init(); //初始化外部SRAM
mem_init(SRAMEX);
LCD_Clear(WHITE);
while(NRF24L01_Check()) //检查NRF24L01是否在位.
{
LCD_ShowString(60,130,200,16,16,"NRF24L01 Error");
delay_ms(200);
LCD_Fill(60,130,239,130+16,WHITE);
delay_ms(200);
}
LCD_ShowString(60,130,200,16,16,"NRF24L01 OK");
showbuf=(u8*)mymalloc(SRAMEX,240*320*2+5);
a=showbuf; //记录初始地址
NRF24L01_TX_Mode();//配置为发送模式
while(NRF24L01_TxPacket(showbuf)!=0); //发送同步信号 通知开始采集图像
delay_ms(1000);
NRF24L01_RX_Mode();//配置为接收模式
LCD_Scan_Dir(U2D_L2R); //从上到下,从左到右
LCD_SetCursor(0x00,0x0000); //设置光标位置
LCD_WriteRAM_Prepare(); //开始写入GRAM
NRF24L01_RX_Mode();//配置为接收模式
while(1)
{
while(NRF24L01_RxPacket(showbuf)!=0); //等待数据接收完毕
showbuf +=32;
receivecount +=32;
if(receivecount >=(320*240*2)) //接收了一屏数据
{
showbuf =a;
receivecount=0;
for(count=0;count<320*240;count++)
{
color=showbuf[receivecount++]&0XFF; //读数据
color<<=8;
color|=showbuf[receivecount++]&0XFF; //读数据
LCD->LCD_RAM=color; //向tft屏写入一个点
}
showbuf =a;
NRF24L01_TX_Mode();//配置为发送模式
while(NRF24L01_TxPacket(showbuf)!=0); //发送同步信号 通知采集下一帧
NRF24L01_RX_Mode();//配置为接收模式
LCD_SetCursor(0x00,0x0000); //设置光标位置
LCD_WriteRAM_Prepare(); //开始写入GRAM
}
}
}
[/mw_shl_code]
</div>
<br /> |
|