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.

PIC16F627A MCU USART Asynch, SPBRG value query

Status
Not open for further replies.

the_merovingian

Member level 1
Joined
Jul 25, 2009
Messages
32
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Location
UK
Activity points
1,558
spbrg

I'm trying to interface a PIC16F627A MCU to a PC (running Linux) via an RS-232 serial interface.

I've chosen to use the 16F627A as it has on-board USART. Presumably the easiest method for comms is for me to use this in asynchronous mode?

I'm a little confused by the values of SPBRG given in the table within the Microchip PDFs (https://ww1.microchip.com/downloads/en/DeviceDoc/31018a.pdf). I intend to run the chip from its internal oscillator (~4MHz) and I want my baud rate to be 9.6k. In table 18-4 and 18-5 (i.e. for when BRGH is 0 and 1 respectively); if Fosc = 4MHz and baud rate = 9.6k, the values for SPBRG are shown as 'NA' (which I'm taking to be not available or not applicable).

Does this mean that I can't run at 9600 baud using the internal oscillator?

Thanks in advance.
 

pic16f627a

Hi,

You are quoting from the Mid range guide, but when you are coding its better to get the final detail from the datasheet of the chip you are using.

The point about
SPBRG are shown as 'NA'
is that you have to consider what you are doing.
With your chosen clock speed of 4mhz the way that translates down to the speed of 9600 baud means it cannot create all the needed transmission pulses in the time allowed.

You will either have to increase your oscillator frequency or decrease your baud rate.

See this tutorial for a good explanation - in the download files for that lesson version 7.7a is the hardware example which does work well.
http://www.winpicprog.co.uk/pic_tutorial7.htm
 

The value you need in SPBRG is 25(decimal) 00011000
You also need to set SPBRGH bit in TXSTA.

Baud Rate = FOSC/(16 (X + 1)) {When SPBRGH=1}

the error is approximately .15%

Added after 1 minutes:

The answer would be RTFM
 


@Kurenai_ryu : I have said that

You also need to set SPBRGH bit in TXSTA.

Added after 34 seconds:

Oops I mistyped SPBRGH instead of BRGH :p
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top