Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Usart problem in Micro C Pro

Status
Not open for further replies.

Raff

Newbie level 4
Joined
Mar 22, 2011
Messages
6
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,337
Hello. Im using PIC16F877. I have tried to program Sharp Distance sensor and try to display the value in USART terminal by using micro C pro. There have 3 pin, RA1, GND and Vin. There have a problem because the value were not display in USART terminal.I have set the serial connection to COM3. This is my C Program.

int Adc;
char txt [6];
void Read_Adc()
{
ADCON0=0b01001001;
ADCON0.GO=1;
while(ADCON0.GO);
Adc=(ADRESH*4)+(ADRESL/64);
}
void main()
{
Delay_ms(1000);
UART1_Init(9600);
Delay_ms(1000);
UART1_Write_Text("raw data:");
UART1_Write(10);
UART1_Write(13);

while(1)
{
Read_Adc();
WordToStr(Adc,txt);
UART1_Write_Text(txt);

}
}

Thanks a lot.
 

If you can't receive anything in the UART terminal, check your MAX232 connections. Make sure also that you are not swapping the TX and RX pins.
If you receive rubbish data, check the BAUD Rate in the terminal and in your software.

Hope this helps.
 

check first if your data from sensor is correctly receive by PIC. 1 way to do this is check it with LEDS or pass it as an output. If it checked out correct, then go the serial connection. Make sure ur MAX232 is correctly connected. Hope this helps
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top