Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <htc.h>
- #include <stdio.h>
- typedef unsigned char byte;
- __CONFIG(1, IESODIS & FCMDIS & RCIO);
- __CONFIG(2, BORDIS & BORV21 & PWRTDIS & WDTDIS);
- __CONFIG(3, MCLRDIS);
- __CONFIG(4, DEBUGDIS & LVPDIS & XINSTEN);
- __CONFIG(5, UNPROTECT);
- __CONFIG(6, WRTEN);
- __CONFIG(7, TRPB);
- #define _XTAL_FREQ 8000000
- #define __delay_us(x) _delay((unsigned long)((x)*(_XTAL_FREQ/4000000UL)))
- #define __delay_ms(x) _delay((unsigned long)((x)*(_XTAL_FREQ/4000UL)))
- byte rx = 0x00;
- //putch implementation for printf
- void putch(unsigned char byte) {
- TXREG = byte;
- while(TRMT == 0); //Wait while sending
- }
- //getch implementation
- unsigned char getch() {
- while(RCIF == 0); //Wait while receiving
- return RCREG;
- }
- void main(void) {
- OSCCON = (OSCCON & 0b10001101) | 0b01110010; //Set oscillator frequency
- //All ports are output
- TRISA = 0x00;
- TRISB = 0x00;
- TRISC = 0x00;
- //Disable A2D
- ADON = 0;
- PORTC = 0x00;
- LATC = 0x00;
- while(1) {
- LATC = 0b01010101;
- __delay_ms(2000);
- LATC = 0xFF;
- __delay_ms(2000);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement