9s12g128的sci程序 求助

2019-03-26 07:58发布

最近在弄9s12g128的单片机,用的是TWR-S12G128的开发板,sci的程序总,但是sci引脚没有数据帧发出,请高手给看看,有啥问题么??谢谢!

#include "derivative.h"
#include <hidef.h>      /* common defines and macros */
#include "project.h"

unsigned char R;
uint16 count;
unsigned char c;
#pragma CODE_SEG NON_BANKED
void sci_init(void)
{
        SCI0CR1 = 0x00;//normal mode;1 start bit and 8 data bits;parity disable;

        SCI0CR2 = 0x0C;//enable receive interrupt

        //Fbus = 8MHz
       
        SCI0BDH = 0x00;//SCI baud rate = SCI bus clock / (16 x SBR[12:0])
        SCI0BDL = 0x34;//baud: 9600
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////


        SCI1CR1 = 0x00;//normal mode;1 start bit and 8 data bits;parity disable;

        SCI1CR2 = 0x0C;//enable receive interrupt

        //Fbus = 8MHz
       
        SCI1BDH = 0x00;//SCI baud rate = SCI bus clock / (16 x SBR[12:0])
        SCI1BDL = 0x34;//baud: 9600
}

void tx(unsigned char tx_data)
{
        while(SCI1SR1_TDRE == 0);
        SCI1DRH = 0x55;  
        SCI1DRL = 0;
        while(SCI1SR1_TC == 0);
}

#pragma TRAP_PROC
void  rx_sr(void)
{
        while(!(SCI0SR1_RDRF == 1));
        if(SCI0SR1_RDRF == 1)
        {
                R = SCI0DRL;
                c = SCI0SR1;//read SCI0SR1 to clear RDRE
        }
               
}
#pragma CODE_SEG DEFAULT 此帖出自小平头技术问答
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。