Author Topic: PIC18F46K42 xpress EVAL Board - UART  (Read 1116 times)

0 Members and 1 Guest are viewing this topic.

Offline arulTopic starter

  • Regular Contributor
  • *
  • Posts: 50
  • Country: in
PIC18F46K42 xpress EVAL Board - UART
« on: November 23, 2018, 02:56:38 pm »
Hi,

I am developing one of the UART program using MPLAB Xpress PIC18F46K42 evaluation board on MPLAB CLOUD IDE.
In this program, FT232R USB UART IC and termite app are used to estabish the communication.
In this case, the LED is 'ON' and 'OFF', but the UART function is not established on termite window.

my code is as follows:


////////////////main function/////////////
void main(void)
{
PORTAbits.RA0 = 1;   //led "ON"
delay_ms(100) ;      //wait for delay

       UART1_Write(a);    ////char (or) uint8_t a = 77; 
       UART1_Write(b);    ////char (or) uint8_t b = 78;
       UART1_Write(c);    ////char (or) uint8_t c = 79;
       UART1_Write(d);    ////char (or) uint8_t d = 80;

PORTAbits.RA0 = 0;   //led "OFF"
delay_ms(100) ;      //wait for delay
}

////////UART Transmit function///////////
void UART1_Write(uint8_t txData)   
{
    while(0 == uart1TxBufferRemaining)
    {
    }

    if(0 == PIE3bits.U1TXIE)   
    {
        U1TXB = txData;
    }
    else
    {
        PIE3bits.U1TXIE = 0;
        uart1TxBuffer[uart1TxHead++] = txData;
        if(sizeof(uart1TxBuffer) <= uart1TxHead)
        {
            uart1TxHead = 0;
        }
        uart1TxBufferRemaining--;
    }
    PIE3bits.U1TXIE = 1;
}
////////////////////////////////////


Please let me know, what is going wrong...
 

Offline JPortici

  • Super Contributor
  • ***
  • Posts: 3461
  • Country: it
Re: PIC18F46K42 xpress EVAL Board - UART
« Reply #1 on: November 23, 2018, 03:01:02 pm »
Please use code tags.
I don't see where the hardware is being initialized.
 
The following users thanked this post: arul

Offline arulTopic starter

  • Regular Contributor
  • *
  • Posts: 50
  • Country: in
Re: PIC18F46K42 xpress EVAL Board - UART
« Reply #2 on: November 24, 2018, 04:28:06 am »
Hi JPortici,

These are hardware intialization:

#define IO_RA0_PORT                 PORTAbits.RA0     ///led initialization
TRISA = 0xFE;                                                       ///led initialization


#define RC6_GetValue()              PORTCbits.RC6      ///tx initialization
TRISC = 0xBF;                                                       ///tx initialization
RC6PPS = 0x13;   //RC6->UART1:TX1;                    ///tx initialization

#define RC7_GetValue()              PORTCbits.RC7      ///rx initialization
U1RXPPS = 0x17;   //RC7->UART1:RX1;                  ///rx initialization

 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf