求助飞思卡尔单片机高手,我用MC9S08LG32单片机和串口调试小助手调试串口的时候,遇到如图这样的问题,黄 {MOD}是串口小助手出来的波形(单片机接收),经放大也是正确的,蓝 {MOD}是单片机输出的波形(单片机发送),我程序做的事情就是接受小助手发的数据并发送回小助手,波特率经过测量差不多也是对的,问题就在于为什么蓝 {MOD}的单片机发送波形会像方波一样,而在蓝 {MOD}高电位的时候经放大发现数据也是对的,但是小助手不显示数值,程序和波形在下面。
#include "hidef.h"
#include "derivative.h" /* include peripheral declarations */
#include "Std_types.h"
#include "SchM.h"
#include "MCAL.h"
#include "Dio.h"
#include "Adc.h"
void UART_Init(void)
{
PINPS4 = 0x00; //enable the Pin port PTF0/TX PTF1/RX
SCGC1_SCI1 = 1; //enable the clock
/* SCI1C1: LOOPS=0,SCISWAI=0,RSRC=0,M=0,WAKE=0,ILT=0,PE=0,PT=0 */
SCI1C1=0x00; /* Configure the SCI */
/* SCI1C3: R8=0,T8=0,TXDIR=0,TXINV=0,ORIE=0,NEIE=0,FEIE=0,PEIE=0 */
SCI1C3=0x00; /* Disable error interrupts */
/* SCI1S2: LBKDIF=0,RXEDGIF=0,??=0,RXINV=0,RWUID=0,BRK13=0,LBKDE=0,RAF=0 */
SCI1S2=0x00;
/* SCI1C2: TIE=0,TCIE=0,RIE=0,ILIE=0,TE=0,RE=0,RWU=0,SBK=0 */
SCI1C2=0x00; /* Disable all interrupts */
SCI1BDH = 0x00; /* Set high divisor register (enable device) */
SCI1BDL = 19; /* Set low divisor register (enable device) */
SCI1C2_TE = 0x01; /* Enable transmitter */
SCI1C2_RE = 0x01;
}
void main(void) {
uint8 ch,aaa;
UART_Init();
while(1) {
while(SCI1S1_RDRF == 0);
ch = SCI1D;
while(SCI1S1_TDRE == 0);
aaa = SCI1S1;
SCI1D = ch;
}
}
大神有已经调通的串口程序就请发给小弟一份吧,初学这块单片机,已经要崩溃了。邮箱184343631@qq。com。感谢!感谢!
-
单片机发送与接受端波形
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
一周热门 更多>