Jump to content

Hugo

Members
  • Content Count

    2
  • Joined

  • Last visited

Community Reputation

0 Neutral

About Hugo

  • Rank
    Newbrie
  1. OK, I've taken Steve's suggestion and used the UART. I've written this code, to send a continuous stream of characters, with slight pauses between. When I run *this* one, data is definitely being sent, but the terminal acts like it's a string of carriage returns and the cursor just blinks faster but nothing gets printed. Is this the proper way to deal with the UART? /* * serial routines for 16f87x with UART */ char _TRISB@0x86; char _SPBRG@0x99; char _RCSTA@0x18; char _TXSTA@0x98; char _PIE1@0x8C; char _INTCON@0x0B; char _TXREG@0x19; #define GIE 0x0007 #define PEIE 0x0006 #define T0IE 0x0005 #define INTE 0x0004 #define RBIE 0x0003 #define T0IF 0x0002 #define INTF 0x0001 #define RBIF 0x0000 void main(void) { _TRISB = 0; _SPBRG = 25; set_bit(_RCSTA, SPEN); // set serial port enable clear_bit(_TXSTA,SYNC); set_bit(_TXSTA,TXEN); // set transmit enable set_bit(_TXSTA,BRGH); // set high baud rate speed set_bit(_PIE1,TXIE); // enable serial transmit interrupts while (1 == 1) { _TXREG = 'x'; delay_ms(200); } }
  2. The serial routines are so simple I'm not quite sure where I've gone wrong, but I have. If someone could set me straight I'd really appreciate it. I'm programming a 16F876 connected to my PC. I get output in my terminal, but it's garbled, as sometimes happens with incorrect baud rates. I've double-checked baud rate, turned off handshaking, etc., but I still get garbage. I assume that getchar() will begin working when I fix this problem, as the receive routines also don't respond (the program hangs waiting for input no matter what I send down the line). Here is my source code:
×
×
  • Create New...