御风逍遥Fly 发表于 2014-5-6 14:48:20

求助:dsPIC33FJ32**的串口Tx到底是哪个管脚?

如题,看了Pic的手册,没有找到啊。

songshanxiaozi 发表于 2014-5-7 10:55:36

仔细看,不可能没有的,什么型号啊

g921002 发表于 2014-5-7 12:02:26

看看是不是用PPS定義所以沒寫。

御风逍遥Fly 发表于 2014-5-7 15:38:35

问题已经解决,型号:dsPIC33FJ32MC204,手册上确实没有标明哪个是默认的TX引脚。需要另行配置的。代码如下:
//波特率9600 8位数据 1位停止位 无校验
void init_UART()
{
       
        //uart1 IO set
        TRISB = (1 << 3);
    RPINR18bits.U1RXR = 3;      //uart1-rxd----RP3 RB3
    RPOR2bits.RP4R = 3;         //TX RP4--RB4
      
        U1MODEbits.UARTEN = 0;        // Bit15 TX, RX DISABLED, ENABLE at end of func
        //U2MODEbits.notimplemented;        // Bit14
        U1MODEbits.USIDL = 0;        // Bit13 Continue in Idle
        U1MODEbits.IREN = 0;        // Bit12 No IR translation
        U1MODEbits.RTSMD = 0;        // Bit11 Simplex Mode
        //U2MODEbits.notimplemented;        // Bit10
        U1MODEbits.UEN = 0;                // Bits8,9 TX,RX enabled, CTS,RTS not
        U1MODEbits.WAKE = 0;        // Bit7 No Wake up (since we don't sleep here)
        U1MODEbits.LPBACK = 0;        // Bit6 No Loop Back
        U1MODEbits.ABAUD = 0;        // Bit5 No Autobaud (would require sending '55')
        U1MODEbits.URXINV = 0;        // Bit4 IdleState = 1(for dsPIC)
        U1MODEbits.BRGH = 0;        // Bit3 16 clocks per bit period
        U1MODEbits.PDSEL = 0;        // Bits1,2 8bit, No Parity
        U1MODEbits.STSEL = 0;        // Bit0 One Stop Bit
       
        // Load a value into Baud Rate Generator.Example is for 9600.
        // See section 19.3.1 of datasheet.
        //U2BRG = (Fcy/(16*BaudRate))-1
        //U2BRG = (37M/(16*9600))-1
        //U2BRG = 240
        U1BRG = FCY/9600/16 - 1;        //24-1
       
        // Load all values in for U1STA SFR
        U1STAbits.UTXISEL1 = 0;        //Bit15 Int when Char is transferred (1/2 config!)
        U1STAbits.UTXINV = 0;        //Bit14 N/A, IRDA config
        U1STAbits.UTXISEL0 = 0;        //Bit13 Other half of Bit15
        //U2STAbits.notimplemented = 0;        //Bit12
        U1STAbits.UTXBRK = 0;        //Bit11 Disabled
        U1STAbits.UTXEN = 0;        //Bit10 TX pins controlled by periph
        U1STAbits.UTXBF = 0;        //Bit9 *Read Only Bit*
        U1STAbits.TRMT = 0;          //Bit8 *Read Only bit*
        U1STAbits.URXISEL = 0;        //Bits6,7 Int. on character recieved
        U1STAbits.ADDEN = 0;        //Bit5 Address Detect Disabled
        U1STAbits.RIDLE = 0;        //Bit4 *Read Only Bit*
        U1STAbits.PERR = 0;                //Bit3 *Read Only Bit*
        U1STAbits.FERR = 0;                //Bit2 *Read Only Bit*
        U1STAbits.OERR = 0;                //Bit1 *Read Only Bit*
        U1STAbits.URXDA = 0;        //Bit0 *Read Only Bit*

        IPC2bits.U1RXIP = 3;        //interupt priority is 3
        IEC0bits.U1RXIE = 1;    //RX interrupt enable
        IFS0bits.U1RXIF = 0;         //clear RX int flag
       
        U1MODEbits.UARTEN = 1;        // And turn the peripheral on
        U1STAbits.UTXEN = 1;       
        // I think I have the thing working now.
}
页: [1]
查看完整版本: 求助:dsPIC33FJ32**的串口Tx到底是哪个管脚?