📄 testtxptr2000.c
字号:
//ICC-AVR application builder : 2005-4-8 21:05:22
// Target : M16
// Crystal: 7.3728Mhz
#include <iom16v.h>
#include <macros.h>
#include <stdio.h>
//void putchar(unsigned char c );
//void puts(unsigned char *s );
#define PTR_CS 0
#define PTR_TXEN 3
unsigned char array[6]={'F','F','0','0','5','5'};
void port_init(void)
{
PORTA = 0x00;
DDRA = 0x00;
PORTB = 0x09;
DDRB = 0x09;
PORTC = 0x00; //m103 output only
DDRC = 0x00;
PORTD = 0x00;
DDRD = 0x00;
}
//UART0 initialize
// desired baud rate: 9600
// actual: baud rate:9600 (0.0%)
// char size: 5 bits
// parity: Disabled
void uart0_init(void)
{
UCSRB = 0x00; //disable while setting baud rate
UCSRA = 0x00;
UCSRC = BIT(URSEL) | 0x04;
UBRRL = 0x2F; //set baud rate lo
UBRRH = 0x00; //set baud rate hi
UCSRB = 0x98;
}
#pragma interrupt_handler uart0_rx_isr:12
void uart0_rx_isr(void)
{
//uart has received a character in UDR
}
//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;
GICR = 0x00;
TIMSK = 0x00; //timer interrupt sources
SEI(); //re-enable interrupts
//all peripherals are now initialized
}
void main(void)
{
init_devices();
PORTB&=~BIT(PB0);
PORTB|=BIT(PB3);
while(1)
{
//puts("FF");
//puts("00");
//puts("55");
puts(array);
}
}
/*void putchar(unsigned char c) //字符输出函数
{
while (!(UCSRA&(1 << UDRE))); //判断上次发送有没有完成
UDR = c;
}
void puts(unsigned char *s)
{
while (*s)
{
putchar(*s);
s++;
}
}*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -