![]() | ![]() | ![]() |
| | |||||||
| Micro Controllers Discuss all aspects of micro controllers - building them, coding them, etc. All controllers are welcome - PIC, BASIC, Z8 Encore!, etc. |
| | LinkBack | Thread Tools | Display Modes |
| | (permalink) |
| hi all, The code below is not working...Can anyone advice on this.I'm using PIC16f877. Code: #include <pic1687x.h>
#include <pic.h>
// Transmitter test program
void main() {
TRISC = 0x00 ; //portC as output
SPBRG = 129; // Set the baud rate to 9.6k
BRGH = 1; // Set high baud rate
SYNC = 0; // Set asynchronous
SPEN = 1; // Enable serial port pins
SREN=0;
TX9 = 0; // Disable 9 bit transmission
TXIE = 0; // Disable tx interrupts
RCIE = 0; // Disable rx interrupts
TXEN = 0; //reset the transmitter
TXEN = 1; // Enable the transmitter
while(1) {
TXEN = 1;
while(!TXIF) { // Checks if the transmit flag is down
continue;
}
TXREG = 0b01010101;
}
} | |
| |
| | (permalink) |
| TX and RX have to be set to input for the UART to work. You should also write to TXREG and then wait for TXIF to be set. Mike. | |
| |
| | (permalink) | |
| Quote:
| ||
| |
| | (permalink) |
| I only use asm on 16F pics but I would guess it would be something like, Code: #include <pic1687x.h>
#include <pic.h>
// Transmitter test program
void main() {
TRISC = 0xc0 ; //portC as output
SPBRG = 129; // Set the baud rate to 9.6k
BRGH = 1; // Set high baud rate
SYNC = 0; // Set asynchronous
SPEN = 1; // Enable serial port pins
SREN=0;
TX9 = 0; // Disable 9 bit transmission
TXIE = 0; // Disable tx interrupts
RCIE = 0; // Disable rx interrupts
TXEN = 0; //reset the transmitter
TXEN = 1; // Enable the transmitter
while(1) {
TXEN = 1;
TXREG = 0b01010101;
while(!TXIF); // Checks if the transmit flag is down
}
} | |
| |
| | (permalink) |
| I am compiling a Problem-Issue Verses Effort-Issue report. I will incorportate this example as an Effort-Issue. | |
| |
| | (permalink) | |
| Quote:
Hi , can you send me your asm code to to test my tx ? I understand that i can add that asm code directly to my C for compilation Thanks in advance | ||
| |
| | (permalink) | |
| Quote:
| ||
| |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
| |
| | ||||
| Title | Starter | Forum | Replies | Latest |
| First Program in assembly, And Programmer Inchworm. | Ayne | Micro Controllers | 10 | 9th March 2007 08:27 PM |
| program for writing and testing circuits | luca-deltodesco | General Electronics Chat | 3 | 13th August 2006 11:17 AM |
| little help with my program please - simple count loop | kud0s | Micro Controllers | 5 | 7th July 2005 10:40 PM |
| PicBasic Keypad program | Sora | Micro Controllers | 0 | 20th April 2004 08:02 PM |
| Program Verify on JMD with ic-prog | monkeyxp | Micro Controllers | 2 | 2nd November 2003 12:56 PM |