s-fr
Newbie
Hey Guys.
I need some help with a project I'm currently working on. Background to the project is, I have to develop a software for a hardware someone else has designed, I need to send chars via UART Communication to a PIC16F627A Microcontroller which should do something after receiving different chars. My problem is that the Guy who designed the hardware tied some transistor circuit onto the TX Pin of the Microcontroller (as you can see in the attachments) and as I use UART I'm not able to use the TX Pin as a commonly GPIO. I think this might be possible though I only have the RX Pin for my UART isn't it?
Please note that the schematic at the attachment is not the original schematic because I'm not allowed to post the original.
Here's my code for UART
And here's my main.c
The code by itself works pretty well, but as I said I'm not able to control the DO_FAN (wich is the TX Pin).
Hope someone can help.
Best regards
I need some help with a project I'm currently working on. Background to the project is, I have to develop a software for a hardware someone else has designed, I need to send chars via UART Communication to a PIC16F627A Microcontroller which should do something after receiving different chars. My problem is that the Guy who designed the hardware tied some transistor circuit onto the TX Pin of the Microcontroller (as you can see in the attachments) and as I use UART I'm not able to use the TX Pin as a commonly GPIO. I think this might be possible though I only have the RX Pin for my UART isn't it?
Please note that the schematic at the attachment is not the original schematic because I'm not allowed to post the original.
Here's my code for UART
C:
#include "UART.h"
#include "main.h"
void UART_Init(const uint32_t BaudRate, const uint8_t BRGH) {
TRISB1 = 1; // RX Pin set as input
TRISB2 = 0; // TX Pin set as output
if (BRGH == 0) {
SPBRG = _XTAL_FREQ/(64*BaudRate) - 1;
TXSTAbits.BRGH = 0;
} else {
SPBRG = _XTAL_FREQ/(16*BaudRate) - 1;
TXSTAbits.BRGH = 1;
}
SYNC = 0; // Asynchronous
SPEN = 1; // Enable serial port pins
TXEN = 0; // enable transmission
CREN = 1; // enable reception
TX9 = 0; // 8-bit reception selected
RX9 = 0; // 8-bit reception mode selected
}
char UART_read_char() {
if(OERR) { // check for Error
CREN = 0; //If error -> Reset
CREN = 1; //If error -> Reset
}
while(!RCIF); // hold the program till RX buffer is free
return RCREG; //receive the value and send it to main function
}
And here's my main.c
C:
void main(void) {
pin_config();
UART_Init(9600, 1);
uint8_t UART_BUFFER;
while(1) {
UART_BUFFER = UART_read_char();
if (UART_BUFFER == 'a') { // LED on
LED_HANDLER(1);
}
else if (UART_BUFFER == 'b') { // LED off
LED_HANDLER(0);
}
else if (UART_BUFFER == 'c') { // Fan on
DO_FAN = 1; //TX Pin
}
else if (UART_BUFFER == 'd') { // Fan off
DO_FAN = 0; //TX Pin
}
UART_BUFFER = '\0';
}
}
The code by itself works pretty well, but as I said I'm not able to control the DO_FAN (wich is the TX Pin).
Hope someone can help.
Best regards