串行通信UART及PROTEUS仿真设计
[10-10 20:38:44] 来源:http://www.88dzw.com 单片机学习 阅读:8214次
文章摘要: { P1=byBuff; uart_send(Tx[i]); } } }}www.88dzw.comatmega64的程序:两个文件,一个是将函数模块化,别一个是主函数,调用(- -!最近习惯将程序模块化。。。)//--uart.c-//这里将通信函数模块化#include <iom64v.h>void uart0_init(void){ UCSR0B = 0x00; //disable while setting baud rate UCSR0A = 0x00; UCSR0C = 0x06; UBRR0L = 0x33; //set baud rate lo UB
串行通信UART及PROTEUS仿真设计,标签:单片机开发,单片机原理,http://www.88dzw.com{
P1=byBuff;
uart_send(Tx[i]);
}
}
}
}
atmega64的程序:
两个文件,一个是将函数模块化,别一个是主函数,调用(- -!最近习惯将程序模块化。。。)
//------------------uart.c---------------------
//----这里将通信函数模块化------------
#include <iom64v.h>
void uart0_init(void)
{
UCSR0B = 0x00; //disable while setting baud rate
UCSR0A = 0x00;
UCSR0C = 0x06;
UBRR0L = 0x33; //set baud rate lo
UBRR0H = 0x00; //set baud rate hi
UCSR0B = 0x18;
}
void uart0_Transmit( unsigned char da
{
/* Wait for empty transmit buffer */
while ( !( UCSR0A & (1<<UDRE0)) )
;
/* Copy ninth bit to TXB8 */
UCSR0B &= ~(1<<TXB80);
//if ( da
//UCSR0B |= (1<<TXB80);
/* Put da
UDR0 = da
}
unsigned char uart0_Receive( void )
{
/* 等待接收数据*/
while ( !(UCSR0A & (1<<RXC0)) )
;
/* 从缓冲器中获取并返回数据*/
return UDR0;
}
//--------------main.c-----------
//--------------------------------
#include <iom64v.h>
#include "spi.h"
#define commun_symbol 0x31
//-----------send a commun_symbol-----
//-----------receive a commun_symbol--
// <--no,continue receive||||||yes-->receive the da
void main()
{
unsigned char bybuff;
DDRB=0xff;
PORTB=0xff;
uart0_init();
{
do
{
bybuff=uart0_Receive();
}
while (bybuff!=commun_symbol);//commun_symbol);
while(1)
{
uart0_Transmit(bybuff);
bybuff=uart0_Receive();
PORTB=(0xff|bybuff);
}
}
}
ok,任务完成了,改天实验一下!
《串行通信UART及PROTEUS仿真设计》相关文章
- › 基于AT90S8515的串行通信及其应用
- › 串行通信UART及PROTEUS仿真设计
- › 基于单片机应用系统的串行通信设计
- › 单片机与计算机串行通信的心得体会
- › 51单片机串行通信程序的设计及调试
- › 基于Z85C30的动目标识别系统的串行通信设计
- 在百度中搜索相关文章:串行通信UART及PROTEUS仿真设计
- 在谷歌中搜索相关文章:串行通信UART及PROTEUS仿真设计
- 在soso中搜索相关文章:串行通信UART及PROTEUS仿真设计
- 在搜狗中搜索相关文章:串行通信UART及PROTEUS仿真设计