Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <p18f4520.h>
- #include <delays.h>
- #include <stdio.h>
- #include "xlcd.h"
- #pragma config WDT = OFF
- int j;
- char rb = '?';
- void initXLCD(void);
- void txtXLCD(void);
- void initUSART(void);
- char reciveByteAndShow(void);
- void sendByte(char c);
- void initUSART(void) {
- // Inicjalizacja modułu USART
- /* Uzupełnij kod */
- TRISC |= 0xC0; // albo TRISC = TRISC | 0xC0;
- TXSTAbits.TX9 = 0; //transmisja 8-bitowa
- TXSTAbits.TXEN = 1; //transmisja mozliwa
- TXSTAbits.SYNC = 0; //tryb asynchroniczny
- TXSTAbits.BRGH = 1; // duza predkosc
- RCSTAbits.SPEN = 1; // port szeregowy aktywny
- RCSTAbits.RX9 = 0; //odbior 8-bitowy
- RCSTAbits.CREN = 1; //wlacza ciagly odbior
- SPBRG = 52;
- }
- char reciveByteAndShow() {
- // Odebranie bajtu danych z komputera PC
- // i wyśietlenie go na wyświetlaczu LCD
- /* Uzupełnij kod */
- while(PIR1bits.RCIF == 0);
- rb = RCREG;
- SetDDRamAddr(0x4F);
- putcXLCD(rb);
- return rb;
- }
- void sendByte(char c) {
- // Wysłanie danych do komputera PC
- /* Uzupełnij kod */
- while(PIR1bits.TXIF == 0);
- if(c>='a'&&c<='z')
- c=c-32;
- else if (c>='A'&&c<='Z')
- c=c+32;
- TXREG = c;
- }
- void main() {
- initXLCD();
- txtXLCD();
- initUSART();
- while(1) {
- rb = reciveByteAndShow();
- Delay1KTCYx(10);
- sendByte(rb);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement