PC通过TTL电平模块接rx3310a接收模块
单片机通过最简单的OOK调制模块发送串口数据
接收模块声表谐振器316.8Mhz;发送模块声表谐振器使用315Mhz的相配合
实现简单的无线数传
单片机m48发送串口数据a
//ICC-AVR application builder : 2010-3-21 下午 10:37:57
// Target : m48
// Crystal: 8.0000Mhz
#include <iom48v.h>
#include <macros.h>
void port_init(void)
{
PORTB = 0x00;
DDRB = 0x00;
PORTC = 0x00; //m103 output only
DDRC = 0x00;
PORTD = 0x00;
DDRD = 0x00;
}
//UART0 initialize
// desired baud rate: 2400
// actual: baud rate:2404 (0.2%)
// char size: 8 bit
// parity: Disabled
void uart0_init(void)
{
UCSR0B = 0x00; //disable while setting baud rate
UCSR0A = 0x00;
UCSR0C = 0x06;
UBRR0L = 0xCF; //set baud rate lo
UBRR0H = 0x00; //set baud rate hi
UCSR0B = 0x18;
}
//数据发送【发送5 到8 位数据位的帧】
void USART_Transmit(unsigned char data)
{
/* 等待发送缓冲器为空 */
while (!(UCSR0A & (1<<UDRE0)))//为1表示寄存器空,可发送数据,否则循环等
;
/* 将数据放入缓冲器,发送数据 */
UDR0 = data;
}
//call this routine to initialize all peripherals
void init_devices(void)
{
//stop errant interrupts until set up
CLI(); //disable all interrupts
port_init();
uart0_init();
MCUCR = 0x00;
EICRA = 0x00; //extended ext ints
EIMSK = 0x00;
TIMSK0 = 0x00; //timer 0 interrupt sources
TIMSK1 = 0x00; //timer 1 interrupt sources
TIMSK2 = 0x00; //timer 2 interrupt sources
PCMSK0 = 0x00; //pin change mask 0
PCMSK1 = 0x00; //pin change mask 1
PCMSK2 = 0x00; //pin change mask 2
PCICR = 0x00; //pin change enable
PRR = 0x00; //power controller
SEI(); //re-enable interrupts
//all peripherals are now initialized
}
void main()
{
init_devices();
while(1)
{
USART_Transmit('a');
}
}