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.

PIC16F877A RS232 running at 38400bps

Status
Not open for further replies.

adwnis123

Full Member level 4
Joined
Jun 19, 2014
Messages
214
Helped
0
Reputation
0
Reaction score
1
Trophy points
18
Activity points
1,737
How do I make a PIC16F877A's USART run at 38400 bps? Because from the manual I cannot understand. I use Mikroelektronika compiler.
 

Try this

Code C - [expand]
1
2
UART1_Init(38400);
Delay_ms(200);

 
Feasibility depends on the oscillator frequency. 8 or 16 MHz e.g. works, also special UART crystal frequencies like 3.69 or 7.37 MHz.
 
Feasibility depends on the oscillator frequency. 8 or 16 MHz e.g. works, also special UART crystal frequencies like 3.69 or 7.37 MHz.

When I try decimal frequencies with the software and not through hardware oscillators, it does not work! Why??
 

When I try decimal frequencies with the software and not through hardware oscillators, it does not work! Why??
What do you mean with "decimal frequencies"? Do you refer to mikroC Software UART library?
I get strange characters at the terminal!!! Why is that?
What's your crystal/oscillator frequency?
 
What do you mean with "decimal frequencies"? Do you refer to mikroC Software UART library?

What's your crystal/oscillator frequency?

In microC pro for PIC v.6, on the left, it has the field "MCU Clock" where you put the frequency. I have chosen 16 Mhz, because it causes the least error from the wanted 38400bps. I don't use external oscillator.
 

16 MHz sounds reasonable, as previously mentioned. Unfortunately there's no fast internal oscillator with PIC16F877A, so I wonder how you are generating the 16 MHz?
 
16 MHz sounds reasonable, as previously mentioned. Unfortunately there's no fast internal oscillator with PIC16F877A, so I wonder how you are generating the 16 MHz?

Really?! The development board has also an oscillator next to the PIC dip40 position! It says 4.000. Maybe it does the job! How I can see that for sure??
 

For the processor features, you'll review the datasheet. It's completely clear in this point.

4 MHz doesn't work for 38k4 hardware UART. May be software UART is an option, but the performance is rather limited.
 
As mentioned by FvM, 4 MHz Clock cannot be used to get 38400 bps baud. You need 16 Mhz Fosc. Either replace the crystal on board or use 9600 bps baudrate with 4 MHz crystal. INTRCOSC can provide max 8 MHz.
 
As mentioned by FvM, 4 MHz Clock cannot be used to get 38400 bps baud. You need 16 Mhz Fosc. Either replace the crystal on board or use 9600 bps baudrate with 4 MHz crystal. INTRCOSC can provide max 8 MHz.

So I change the crystal into 16MHz. Do I nedd any changes in the code, or I just change the option (on the left field of microC PRO for PIC ) into 16MHz and that's all??
 

Set it to 16 MHz and on the left side drop down list for OSC type choose HS.
 
Set it to 16 MHz and on the left side drop down list for OSC type choose HS.

I used 16MHz crystal, strange characters displayed. I used 18.432MHz crystal, again strange characters displayed!!!
 

Try these.
 

Attachments

  • Zigbee_PIC.rar
    49 KB · Views: 76

Yes, Is ZigBee baudrate configured properly ? The baudrates should match. ZigBee work at 3.3V. PIC works at 5V. ZigBee might be damaged if ZigBee directly connected to PIC UART pins.
 

Hello, Is there any reliable circuit with MAX232 you have checked and works, because I found the error! I have connected the PIC with the TTL Tx1,Rx1 of the zigbee, whereas the other zigbee that is connected to the PC, is connected through the RS232 Tx2,Rx2.
I use these zigbees

**broken link removed**
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top