Untitled

mail@pastecode.io avatar
unknown
plain_text
6 months ago
2.3 kB
1
Indexable
Never
#include"Initilize-System.h"
#include"lcd.h"
#include "UART.h"
int main(void) {

    /* TRISX. It is used to define the direction of port  X (0 is output, 1 is input)
     *  _TRISXxx= 0 or 1 used to define the direction of one pin of port as input or output 
     *  diffrent method to write to the port or latch:
     *_LATXxx=0 or 1;
     * _RXxx= 0 or 1;
     * LATX= value ;
     * PORTX= value;
     * _ANSXxx Analog Function Selection bits
           // 1 = Pin is configured in Analog mode; I/O port read is disabled
           // 0 = Pin is configured in Digital mode; I/O port read is enabled
     * X is port name and xx is pin number.
     * Writing LATx is the same as writing PORTx, both writes go to the latch.
     * LEDs (D3 --> D10 , A0-->A7) 
     * (S3,RD6,_ANSD6) , (S4,RD13,NO _ANS for RD13) , (S5,RA7,_ANSA7, overlaps with LED D10) (S6,RD7,_ANSD7)
     * Lcd_Init(void); This function must be called before any other lcd functions. It initializes the LCD module with above defined connections.
     * Lcd_Clear(void); To clear LCD use this function
     * Lcd_gotoxy(char a, char b); This function can be used to set cursor position of the LCD, upper left position is (1,1)
     * Lcd_Char(char a); This function will display c on the next cursor position of the LCD. You can print strings and characters using this function. You can also use following backslash character constants for sending different commands to LCD.
     * Lcd_String(char *a); To print a string to  use this function.
     *Lcd_SR(void);To shift display right use this function.
     * Lcd_SL(void); To shift the display left use this function.
     * Lcd_Cursor_ON(void);This function can be used to turn the cursor on.
     * Lcd_Cursor_Off(void); This function can be used to turn the cursor  off.
     *  */
    
    TRISA = 0;
//define character variable
    char cChar;

// Initialize the LCD
    Lcd_Init();
// Call uart1 configurations
    uart1( );
 printf("Hello its me (Explorer 16/32 )\n");  // Write welcome text to standard output


    while (1) {
cChar=GetCharU1(); // receiving character from UART1
      char i=cChar;
       i=i<<4;
       LATA=i;

printf("Received ASCII value: %d\r", i);
  
Lcd_Char(cChar);  // print the character on LCD
    }
    
    return 0;
}
Leave a Comment