Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

UART Question

Status
Not open for further replies.

Pete_UK

New Member
Good afternoon all,

I've started my first microcontroller project where i'm designing a USB interface to control 32 relays. I'm currently preparing to begin the construction of a prototype but would like to gain some advice from people who have experience with the PIC's UART.

Is it essential that an external oscillator or resonator is used to provide an accurate clock source for the PIC? I have read a present thation from Microchip that says it is essential, but is that really true? Could I get away with just using the internal RC oscillator?

Thanks for any responses,

Pete
 
Good afternoon all,

I've started my first microcontroller project where i'm designing a USB interface to control 32 relays. I'm currently preparing to begin the construction of a prototype but would like to gain some advice from people who have experience with the PIC's UART.

Is it essential that an external oscillator or resonator is used to provide an accurate clock source for the PIC? I have read a present thation from Microchip that says it is essential, but is that really true? Could I get away with just using the internal RC oscillator?

Why talk about UART's when you're wanting to use USB?.

The internal oscillator is fine at 9600 baud, which is mostly as fast as you need to go.

If you want USB, check out the UBW

UBW (USB Bit Whacker) Project

Which already does pretty well what you're wanting to.
 
Hi Nigel,

Thanks for the pointer.

The reason why I decided to take the UART route was because it seemed simpler and I have had some experience with it and also because it appeared to be a good starting place for learning about communications.

Have you had any encounters with the PIC18F4550 at all? Would it be as easy to set-up and write a program for than a 16F628?

Thanks,

Pete
 
Last edited:
Hi Nigel,

Thanks for the pointer.

The reason why I decided to take the UART route was because it seemed simpler and I have had some experience with it.

Have you had any encounters with the PIC18F4550 at all? Would it be as easy to set-up and write a program for than a 16F628?

It's much the same - were you planning using a serial/USB adaptor to give you USB then?.
 
Hi Nigel,

Yes, I have an FT232BL IC from FTDI. I think I'll give the 18F4550 a go once i've proved that my original design works, although the datasheet for it looks a lot more intimidating!

Pete
 
Hi Nigel,

Yes, I have an FT232BL IC from FTDI. I think I'll give the 18F4550 a go once i've proved that my original design works, although the datasheet for it looks a lot more intimidating!

Pete

I have used the FT232RL with a PIC16F628A running on the internal oscillator with no problem. Also, the FT232RL generates its clock internally with no external crystal required. IIRC you need it with the FT232BL.

So, the FT232 IC is a simple way to add USB capability to UART-based programs. Programming a PIC18F4550 for true USB is much more complicated and it is done with C language.

BTW which programming language are you going to use?
 
Last edited:
Hi eng1,

I'm going to be using Assembler/y to program the PIC.

Thanks for the tip on the FT232. Am I write in saying the internal clock of that IC is used to access an EEPROM chip? I also remembering reading that the external clock source needs to be used to achieve higher accuracy to meet the USB standard.

Pete
 
The datasheet of the FT232Rl describes the internal oscillator as follows:

Internal 12MHz Oscillator - [FONT=Verdana,Verdana][FONT=Verdana,Verdana]The Internal 12MHz Oscillator cell generates a 12MHz reference clock. This provides an input to the x4 Clock Multiplier function. The 12MHz Oscillator is also used as the reference clock for the SIE, USB Protocol Engine and UART FIFO controller blocks. [/FONT][/FONT]

This is illustrated by the block diagram in the datasheet of the FT232RL.

[FONT=Verdana,Verdana]
[/FONT]
 
Last edited:
In general, the internal oscillator IS accurate enough for serial in most cases. But YOU need to calculate the possible maximum possible error between tx and rx. Read datasheet. Also note that the UART baud rate can only be "tuned" to digitally quantified numbers in the baud field. Sometimes we find that baud field has to be 24.3333333.... Well, I can't enter that. I have to enter 24, in doing so I create a +1.4% baud rate mismatch from the intended rate, ok in itself, but it contributes to the total error.

If the FT232RI has that 12MHz osc available on a pin, why not use that as the PIC's external OSC input? Since it's used for USB, it's gotta be more accurate than the PIC's internal OSC. But the brilliance is that error won't matter. Say the FT232RI was crazy messed up and the clock was 10% too fast. OK, the USB might not work, but the point I want to make is that it'll send and read the serial data 10% too fast too, but... the PIC will be clocked 10% too fast so it sends and receives 10% too fast, exactly in sync with the FT232.

Curiously enough, IIRC the UART baud rate doesn't matter, only a certain % of baud mismatch error is tolerable before the last bit of a serial byte falls outside the margin of the majority-detection sample period.


 
Last edited:
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top