PIC16F688 USART problem


Closed Thread
Results 1 to 7 of 7
  1. #1
    Kees Reedijk's Avatar
    Kees Reedijk Guest

    Default PIC16F688 USART problem

    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

  2. #2
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    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,
    DT

  3. #3
    Kees Reedijk's Avatar
    Kees Reedijk Guest


    Did you find this post helpful? Yes | No

    Default

    Thanks Darrel, that was indeed the problem, I have set the registers manually and now it works fine.

  4. #4
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    That was quick!

    Nice to see someone that's not affraid of the datasheets.

    Good work.

    regards,
    DT

  5. #5
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    Yup!
    But in case some are afraid of datasheet, if they use the Calc i posted, they only have to modify the generated...
    Code:
    DEFINE HSER_RCSTA 90h
    DEFINE HSER_TXSTA 20h
    DEFINE HSER_SPBRG 51 ' 1200 Bauds
    to
    Code:
    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.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  6. #6
    Join Date
    Mar 2006
    Location
    INDIA
    Posts
    89


    Did you find this post helpful? Yes | No

    Talking

    Quote Originally Posted by mister_e
    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

  7. #7
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    As now the PICMultiCalc is still on testing and development when time permit.
    AS now, it include
    1. USART SPBRG calc: SPBRG value, error % and generate PBP DEFINE, i'll add the Register stuff too
    2. 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
    3. 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.
    4. PWM Calc: TBA.

    In meantime the old HSER Calc is available Here

    There's no release date for the PICMultiCalc. Before christmas for sure


    Quote Originally Posted by precision
    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!
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

Similar Threads

  1. Usart problem with 18F4550
    By maus in forum Serial
    Replies: 7
    Last Post: - 3rd November 2009, 03:54
  2. byte Tx w/ USART 16f876a problem
    By GargamelDigi in forum mel PIC BASIC
    Replies: 2
    Last Post: - 15th July 2008, 05:50
  3. USART Problem , but don't know where, in pc? or in PIC?
    By precision in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 15th July 2007, 08:12
  4. problem with USART
    By leemin in forum Serial
    Replies: 4
    Last Post: - 11th December 2006, 17:56
  5. USART and interrupt latency - not a problem
    By barkerben in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 18th January 2005, 22:57

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts