我现在有自己编写的程序,可是就是不可以进行SCI通信,各位前辈请指教指教,是配置错了还是程序别的问题。
#include <hidef.h> /* for EnableInterrupts macro */
#include <MC68HC908EY16.h> /* include peripheral declarations */
void EY16_Init(void)
{
CONFIG1=0x39;
/*
* 0b00111001
* ||||||||__ COP Module Disabled
* |||||||___ STOP is illegal
* ||||||____ STOP Mode Recovery in 4096 Cycles
* |||||_____ LVI Operates in 5 V
* ||||______ LVI Power Disabled
* |||_______ LVI Resets Disabled
* ||________ LVI Disabled during STOP
* |_________ COP large Timeout
*/
CONFIG2=0x0D;
/*Internal data bus clock source used as clock source for SCI*/
/*
* 0b00001101
* ||||||||__ Disables SS pullup resistor
* |||||||___ Oscillator disabled during stop mode
* ||||||____ Enables extra divide by 128 prescaler in timebase module
* |||||_____ Allows PTC4/OSC1 to be an external clock connection
* ||||______ ICG set for fast external crystal operation
* |||_______ PTC3/OSC2 functions as an I/O port pin
* ||________ Internal data bus clock used as clock source for ESCI
* |_________ R
*/
}
//串口初始化函数
//波特率:4800 起始位:1 数据长度:8 停止位:1 无奇偶校验
void SCI_Init()
{
SCC1_ENSCI =1; //SCI使能
SCC2_TE=1; //发送使能
// SCC2_SCRIE=1; //接收中断使能
SCC2_RE=1; //接收使能
SCC3=0; // disenable all the interrupt
//BaudRate = fbus/(64*BPD*BD*(PD+PDFA))
SCBR_SCP = 0; //BPD=1 (Option 1 3 4 13)
SCBR_SCR = 0; //BD=1 (Option 1,2,4,8,16,32,64,128)
SCPSC_PSSB = 0x8; //PDFA=8/32 (Option 0/32 1/32...31/32)
SCPSC_PS = 0x2; //PD=3 (Option 2 3 4 5 6 7 8)
// for Debug fbus = 1.2 MHz
/*SCBR_SCP = 0; //BPD=1 (Option 1 3 4 13)
SCBR_SCR = 1; //BD=4
SCPSC_PSSB = 0; //PDFA=0 (Option 0/32 1/32...31/32)
SCPSC_PS = 1; //PD=2 (Option 2 3 4 5 6 7 8) */
}
void SCI_Transmit(unsigned char data)
{
while(!SCS1_SCTE); //等待发送缓冲区空
SCDR=data; //把数据放入发送缓冲区
}
void SCI_Receive(unsigned char data2)
{
while(!SCS1_SCRF); //清0
data2=SCDR; //读取接收缓冲区
}
void main(void) {
// EnableInterrupts; /* enable interrupts */
/* include your code here */
unsigned char data,data2;
data=0x55;
data2=0x55;
EY16_Init();
SCI_Init();
SCI_Receive(data2);
SCI_Transmit(data);
}
欢迎光临 电子技术论坛_中国专业的电子工程师学习交流社区-中电网技术论坛 (http://bbs.eccn.com/) | Powered by Discuz! 7.0.0 |