Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronic 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.

Register Log in

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 (http://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.
 

wp100

Advanced Member level 5
Joined
May 15, 2009
Messages
3,056
Helped
883
Reputation
1,781
Reaction score
736
Trophy points
113
Location
Prime Meridian
Activity points
0
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
 

E

eXnol

Guest
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
 

millwood

Advanced Member level 3
Joined
Jul 2, 2009
Messages
734
Helped
80
Reputation
164
Reaction score
35
Trophy points
1,308
Activity points
5,088

E

eXnol

Guest
@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.
Toggle Sidebar

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top