-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
5 changed files
with
78 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
#include <pic16f1825.h> | ||
#include <stdint.h> | ||
|
||
#include "uart.h" | ||
|
||
static __code uint16_t __at (_CONFIG1) configword1 = _FOSC_INTOSC & _WDTE_OFF & _PWRTE_ON & _MCLRE_OFF & _CP_OFF & _CPD_OFF & _BOREN_OFF & _CLKOUTEN_OFF & _IESO_OFF & _FCMEN_OFF; | ||
static __code uint16_t __at (_CONFIG2) configword2 = _WRT_OFF & _PLLEN_OFF & _STVREN_OFF & _LVP_OFF; | ||
|
||
|
||
/***************************************************************************** | ||
Init_hardware() | ||
Initializes all used peripherals of the PIC chip. | ||
****************************************************************************/ | ||
static void Init_hardware(void) { | ||
//----------------------------- | ||
// Clock initialization | ||
OSCCON = 0b01111000; // 16MHz: 4x PLL disabled, 8 MHz HF, Clock determined by FOSC<2:0> | ||
|
||
//----------------------------- | ||
// IO Port initialization | ||
PORTA = 0; | ||
LATA = 0; | ||
ANSELA = 0; | ||
APFCON0 = 0b00000000; // Use RC4/RC5 for UART TX/RX; RA4 for T1G | ||
APFCON1 = 0; | ||
TRISA = 0b11111111; // Make all ports A input | ||
TRISC = 0b11111111; // Make all ports C input | ||
|
||
INTCON = 0; | ||
} | ||
|
||
|
||
/***************************************************************************** | ||
main() | ||
No introduction needed ... | ||
****************************************************************************/ | ||
void main(void) { | ||
Init_hardware(); | ||
Init_UART(); | ||
|
||
while (1) { | ||
uint8_t b; | ||
|
||
b = UART_read_byte(); | ||
UART_send(b); | ||
} | ||
} | ||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#ifndef __UART_H | ||
#define __UART_H | ||
|
||
extern void Init_UART(void); | ||
extern uint8_t UART_read_byte(void); | ||
extern void UART_send(uint8_t); | ||
extern void UART_send_uint(uint16_t); | ||
extern void UART_send_uchar(uint8_t); | ||
|
||
#endif /* __UART_H */ |