View Full Version : PIC16F688 USART problem
Kees Reedijk
- 1st October 2006, 16:52
Hi there
I have a strange problem in trying a pic16F688 to communicate over the usart.
When I use the HSEROUT command the pic sort of freezes, my led stops blinking. When using the SEROUT command all is fine. It must be something simple, I just don't see it. Anyone ?
thanks. I'm using PBP2.45. Here's my code:
[code]
@ device pic16F688, pwrt_on, mclr_off, protect_off, wdt_on, intrc_osc
'INCLUDE "modedefs.bas" ' for serial output macro
define osc 4
' Set receive register to receiver enabled
DEFINE HSER_RCSTA 90h
' Set transmit register to transmitter enabled
DEFINE HSER_TXSTA 20h
' Set baud rate
DEFINE HSER_BAUD 1200
DEFINE HSER_CLROERR 1
ANSEL = %00000000 ' no analog inputs
CMCON0 = %00000111 ' comparators off
TRISA = %00000000
PORTA = %00000000
TRISC = %00100000
PORTC = %00000000
led VAR PORTA.5
loop:
' SerOut PORTC.4,T1200,["this works",10,13]
HSEROUT ["this not",10,13]
pause 200
toggle led
GoTo loop
Darrel Taylor
- 1st October 2006, 17:50
There's a Patch for PBP 2.46 that "Fixes Hserin/Hserout defines for PIC16F688"
I assume it was also a problem in 2.45. The patch won't work on 2.45
You'll probably need to set the SPBRG, SPBRGH and BAUDCTL registers manually.
HTH,
Kees Reedijk
- 1st October 2006, 18:14
Thanks Darrel, that was indeed the problem, I have set the registers manually and now it works fine.
Darrel Taylor
- 1st October 2006, 18:35
That was quick!
Nice to see someone that's not affraid of the datasheets. :cool:
Good work.
regards,
mister_e
- 1st October 2006, 22:12
Yup!
But in case some are afraid of datasheet, if they use the Calc i posted, they only have to modify the generated...
DEFINE HSER_RCSTA 90h
DEFINE HSER_TXSTA 20h
DEFINE HSER_SPBRG 51 ' 1200 Bauds
to
RCSTA=$90
TXSTA=$20
SPBRG= 51 ' 1200 Bauds
I'll add this feature in the next PicMultiCalc. It's handy when you don't use HSERIN/HSEROUT but just reading/writing to/from RCREG/TXREG.
precision
- 2nd October 2006, 04:49
Yup!
I'll add this feature in the next PicMultiCalc. It's handy when you don't use HSERIN/HSEROUT but just reading/writing to/from RCREG/TXREG.
._____________________________________________
There's no problem. Only learning opportunities.
.
But i have some problem. I am hasty for your code, Sir Steve.
I don't know how Young you are with your great post ( 2660) , but im only 20 years and i compiling your all post as pdf file to learn. Yaaa when i compleet this ebooks, i also add the post of sayzer 's , I think This is great opportunities for me.
Your matrix keyboard code is great working.
Please post your code of PicMultiCalc on HSER.
I am waaaaaaaaaaaaaaaaaaaing
Thanks
mister_e
- 2nd October 2006, 04:59
As now the PICMultiCalc is still on testing and development when time permit.
AS now, it include
USART SPBRG calc: SPBRG value, error % and generate PBP DEFINE, i'll add the Register stuff too
Timer calc: Select the crystal speed, select a time mode (8 or 16 Bit), select a prescaller, assign a TMRx pre-load value and know in snap the Overflow interrupt delay
Timer Helper:select the oscillator speed, enter your expected delay (uSec or mSec) and it will produce you a report on how to set the Timer (prescaller, Pre-load) AND also it will return the calculated value.
PWM Calc: TBA.
In meantime the old HSER Calc is available Here (http://www.picbasic.co.uk/forum/attachment.php?attachmentid=981&d=1153512406)
There's no release date for the PICMultiCalc. Before christmas for sure :D
I don't know how Young you are with your great post ( 2660) , but im only 20 years and i compiling your all post as pdf file to learn. Yaaa when i compleet this ebooks, i also add the post of sayzer 's , I think This is great opportunities for me.
I'm 33. Nice to hear such great comments!
Have fun!
Powered by vBulletin® Version 4.1.7 Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.