Hi folks,
I am trying to send a data frame over uart of pic12F1572.
I want to send an frame from PC terminal [I use Hterm] in the format "RGBFF00F0\n" and receive it at PIC.
I have done code but somehow I found it's not working
anyone have the idea?
a code ,hint or solution is highly appreciated
thanks a lot
Here is my code
I am trying to send a data frame over uart of pic12F1572.
I want to send an frame from PC terminal [I use Hterm] in the format "RGBFF00F0\n" and receive it at PIC.
I have done code but somehow I found it's not working
anyone have the idea?
a code ,hint or solution is highly appreciated
thanks a lot
Here is my code
C:
#include <xc.h>
#include "main.h"
#include "config.h"
#include "TYPEDEF_Definitions.h"
#include "PIC_12_Timer0.h"
#include "PIC_12_UART.h"
#include "System_init.h"
#include "Pin_manager.h"
#include "LED.h"
#define BUFFER 0x10
#define _XTAL_FREQ 16000000
// // CONFIG1
// #pragma config FOSC = INTOSC // (INTOSC oscillator; I/O function on CLKIN pin)
// #pragma config WDTE = OFF // Watchdog Timer Enable (WDT disabled)
// #pragma config PWRTE = OFF // Power-up Timer Disable (PWRT Enabled) //change
// #pragma config MCLRE = OFF // MCLR Pin Function Select (MCLR/VPP pin function is MCLR) //change
// #pragma config CP = OFF // Flash Program Memory Code Protection (Program memory code protection is disabled)
// #pragma config BOREN = OFF // Brown-out Reset Enable (Brown-out Reset disabled)
// #pragma config CLKOUTEN = OFF // Clock Out Enable (CLKOUT function is disabled. I/O or oscillator function on the CLKOUT pin)
// // CONFIG2
// #pragma config WRT = OFF // Flash Memory Self-Write Protection (Write protection off)
// #pragma config PLLEN = OFF // PLL Enable (4x PLL disabled)
// #pragma config STVREN = ON // Stack Overflow/Underflow Reset Enable (Stack Overflow or Underflow will cause a Reset)
// #pragma config BORV = LO // Brown-out Reset Voltage Selection (Brown-out Reset Voltage (Vbor), low trip point selected.)
// #pragma config LPBOREN = OFF // Low Power Brown-out Reset enable bit (LPBOR is disabled)
// #pragma config LVP = ON // Low-Voltage Programming Enable (High-voltage on MCLR/VPP must be used for programming
// /*
// */
//----------------Transmiter[Master]----------------------/
void main()
{
uint8_t color , receivedByte ,data_flag;
uint8_t input , i;
uint8_t data [];
SYSTEM_Initialize();
LATA = 0x00;
//TRISA = 0X05;
UART_Init(); //Initialize UART
while (1)
{
if ( UART_DataReady() ) // If data is received,
{
//LATAbits.LATA1 = 0;
receivedByte = UART_Read();
LATAbits.LATA2 = 1;
// if ( receivedByte == 'R')
// {
// LATAbits.LATA1 = 1;
// }
for (i = 0; i<20 ; i++)
{
//if ( receivedByte != '\n')
if ( receivedByte == 'R')
{
data[i] = receivedByte;
LATAbits.LATA1 = 1;
}
else
{
LATAbits.LATA2 = 0;
data = '\0';
data_flag = 1; //set flag
}
}
}
}
Last edited by a moderator: