chandra
Newbie level 6
PIC24HJ UART TX problem
I am using 24hj128gp306 and want to establish connection with PC terminal programm at 115200bps.PIC24HJ I am using UART2.
But i am not getting any characters at pc.Anybody can check the code and help me.
#include <p24Hxxxx.h>
#include<libpic30.h>
#include<uart.h>
#define FCY 7372800 //FCY=FOSC/2
#define BAUDRATE 115200
#define BRGVAL ((FCY/BAUDRATE)/16)-1
/// Macros Configuration
_FOSCSEL(FNOSC_PRI);
_FOSC(FCKSM_CSDCMD & OSCIOFNC_OFF & POSCMD_HS);
_FWDT(FWDTEN_OFF);
_FPOR(FPWRT_PWR1);
_FGS(GCP_OFF);
int main()
{
unsigned int i;
char Txdata[] = {'M','i','c','r','o','c','h','i','p',' ','I','C','D','2','\0'}; /// Chars to transmit
_ODCF5 =0; // openr Drain Configuration
_TRISF5 = 0; // Tx pin is output pin
_LATF5 = 1; // output Latch
U1MODEbits.STSEL = 0; // 1-stop bit
U1MODEbits.PDSEL = 0; // No Parity, 8-data bits
U1MODEbits.ABAUD = 0; // Autobaud Disabled
U1BRG = BRGVAL; // BAUD Rate Generator Prescalar Refer Table 3-10 9600
U1STAbits.UTXISEL0 = 0;
U1STAbits.UTXISEL1 = 0;
IEC0bits.U1TXIE = 0;
U1MODEbits.UARTEN = 1; // Enable UART
U1STAbits.UTXEN = 1; // Enable UART Tx
//for(i=0;1<4160;i++);
putsUART1 ((unsigned int *)Txdata);
//while(1){}
return 0;
}
I am using 24hj128gp306 and want to establish connection with PC terminal programm at 115200bps.PIC24HJ I am using UART2.
But i am not getting any characters at pc.Anybody can check the code and help me.
#include <p24Hxxxx.h>
#include<libpic30.h>
#include<uart.h>
#define FCY 7372800 //FCY=FOSC/2
#define BAUDRATE 115200
#define BRGVAL ((FCY/BAUDRATE)/16)-1
/// Macros Configuration
_FOSCSEL(FNOSC_PRI);
_FOSC(FCKSM_CSDCMD & OSCIOFNC_OFF & POSCMD_HS);
_FWDT(FWDTEN_OFF);
_FPOR(FPWRT_PWR1);
_FGS(GCP_OFF);
int main()
{
unsigned int i;
char Txdata[] = {'M','i','c','r','o','c','h','i','p',' ','I','C','D','2','\0'}; /// Chars to transmit
_ODCF5 =0; // openr Drain Configuration
_TRISF5 = 0; // Tx pin is output pin
_LATF5 = 1; // output Latch
U1MODEbits.STSEL = 0; // 1-stop bit
U1MODEbits.PDSEL = 0; // No Parity, 8-data bits
U1MODEbits.ABAUD = 0; // Autobaud Disabled
U1BRG = BRGVAL; // BAUD Rate Generator Prescalar Refer Table 3-10 9600
U1STAbits.UTXISEL0 = 0;
U1STAbits.UTXISEL1 = 0;
IEC0bits.U1TXIE = 0;
U1MODEbits.UARTEN = 1; // Enable UART
U1STAbits.UTXEN = 1; // Enable UART Tx
//for(i=0;1<4160;i++);
putsUART1 ((unsigned int *)Txdata);
//while(1){}
return 0;
}