Jump to content
  • 0

Usart two problems


btb4198

Question

I have my Usart one  working, but the usart two is not. I have them set up the same way in the code, so the code must be right. I  just keep getting 0 bytes or nothing at all and I do not know why. I am using a ChipKit uC32 board and I have a Sparkfun RS232 Shifter connected to my computer. I have RX from the Shifter wired to TX2 on the uC32 and U2TX(pin32) wired to U2RX(pin 31). and I see the light blinking for RX but it is not working.  I used to have this same problem with usart1 but I started using the usb port and it work for usart 1, but usart is not.

 

what should I do ?

here i my code:

TRISBbits.TRISB2 = 0;//set portB pin to output
TRISDbits.TRISD9 =0; //set portB pin to output

OpenUART1(UART_EN| UART_NO_PAR_8BIT | UART_1STOPBIT , UART_RX_ENABLE|UART_TX_ENABLE, (FPb /16/desired_baud) - 1 );
OpenUART2(UART_EN| UART_NO_PAR_8BIT | UART_1STOPBIT , UART_RX_ENABLE|UART_TX_ENABLE, (FPb /16/desired_baud) - 1 );

void Modbus_Send(void)
{
    unsigned char Message[8] ;
    Message [0] = 1;
    Message [1] = 3;
    Message [2] = 12;
    Message [3] = 130;
    Message [4] = 0;
    Message [5] = 1;
   // CRCfunction(Message, 6);
     while(BusyUART2());
    
    putsUART2(Message);
    return;
    
}

 

also I tested the Sparkfun RS232 Shifter and it works fine. also, I have 5v from the ChipKit uC32 board doing to the Sparkfun RS232 Shifter.

IMG_1561.JPG

Link to comment
Share on other sites

3 answers to this question

Recommended Posts

Hi btb4198,

The pins you listed for the U2RX and U2TX are for the PIC32 specifically, not the silk screen pins where you'll physically plug in your wires. U2RX is on silk screen pin 39 and U2TX is on silk screen pin 40.

Let me know if this helps!

Thanks,
JColvin

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...