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
Question
btb4198
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.
Link to comment
Share on other sites
3 answers to this question
Recommended Posts
Archived
This topic is now archived and is closed to further replies.