/*********************************************************************************** Project: PRINT USART Filename: PRINTTEST.c Prozessor: PIC 16F877 Compiler: HI-TECH v8.01PL3 Demoprogramm ***********************************************************************************/ #define __16F877 #include #include #include "printtest.h" __CONFIG(0x3F75); //WDT OFF #define PORTBIT(adr, bit) ((unsigned)(&adr)*8+(bit)) #define INIT_PORTS {TRISA = 0xFF; TRISB = 0x6F; TRISC = 0xBF; TRISD = 0xFF; TRISE = 0x07;} //Registers initializations void RegInit(void); //Global static int p; void putch(char c); char getch(void); void _nop_(void); //---------------------------------------------------------------------------------- main(void) //---------------------------------------------------------------------------------- { RegInit(); while(1) { CLRWDT(); printf("hallo"); for (p=0;p<16000;p++) {_nop_();} } } //---------------------------------------------------------------------------------- void RegInit(void) //---------------------------------------------------------------------------------- { //Pull-up za port B RBPU = 0; // Inicializacija vhodov INIT_PORTS; // inicializacija serijskega kanala PIC-a BRGH=1; // high baud rate // SPBRG=22; // set the baud rate 22-9600Bd, 11-19200 (3.58MHz) SPBRG=25; // set the baud rate 25-9600Bd (4MHz) SYNC=0; // asynchronous SPEN=1; // enable serial port pins CREN=1; // enable reception SREN=0; // no effect TXIE=0; // disable tx interrupts RCIE=0; // disable rx interrupts TX9=0; // 0-8 or 1-9bit transmission RX9=0; // 0-8 or 1-9bit reception TXEN=1; // enable the transmitter } //---------------------------------------------------------------------------------- void putch(char c) //---------------------------------------------------------------------------------- { while(!TXIF)continue; /* set when register is empty */ TXREG=c; } //---------------------------------------------------------------------------------- char getch(void) //---------------------------------------------------------------------------------- { while(0); /*(!RCIF)continue;*/ /* set when register is not empty */ return RCREG; } //---------------------------------------------------------------------------------- void _nop_(void) //---------------------------------------------------------------------------------- { asm("nop"); }