Hersin quick question


Closed Thread
Results 1 to 16 of 16

Hybrid View

  1. #1
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,624


    Did you find this post helpful? Yes | No

    Default Re: Hersin quick question

    Hi Andy,
    Intermittent results you say :-)

    It sits there waiting for a character for 5 seconds, if none is received it goes to mainloop where you spend "considerable" time before you eventually get back the connected subroutine where you again check for an "A". Now, if you happen to send an "A" during the time that HSERIN isn't actually waiting for one it will be missed.

    Might be what's happening.

    Start by removing all the PAUSE statements you have within your main loop and see if it gets "better". Even so, there will be times where HSERIN isn't executing when you send that "A". An interrupt would be a good option here but you could possibly get away with simply polling the receive buffer, if you stick to sending it a single character.

    /Henrik.

  2. #2
    Join Date
    May 2012
    Location
    Merseyside, UK
    Posts
    237


    Did you find this post helpful? Yes | No

    Default Re: Hersin quick question

    Hiya

    Well intermittent read as nothing at all .

    Clock works ok ....The IR works ok as do the LEDs ....Proves processor is running

    The pauses were put in as a desperate attempt to see something ....

    The Bluetooth is working as I have had a terminal monitor on both TX and RX ....again all good 😁.

    Hserout working fine as I can see Timeout message

    Andy

  3. #3
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,624


    Did you find this post helpful? Yes | No

    Default Re: Hersin quick question

    Which device and out of curiousity, what's up with the slightly odd baudrate?

    Well nothing and intermittent isn't quite the same :-)
    Are you SURE the serial data is actually getting to the correct pin on the PIC? Have you checked? Scope, logic analyzer?

    Write up a simple program to make sure you have a working serial connection both ways, something like:
    Code:
    Main:
       HSERIN 5000, timeout,[char]
       HSEROUT[char]
    Goto main
    
    Timeout:
       HSEROUT["Nope, not this time. Lets try again",13]
    Goto Main
    EDIT: Sorry, didn't realise serial was over the BT...I guess data IS comming to the correct pin then.

  4. #4
    Join Date
    May 2012
    Location
    Merseyside, UK
    Posts
    237


    Did you find this post helpful? Yes | No

    Default Re: Hersin quick question

    Hiya
    I wondered about the 9615 But manual says is should be that rather than 9600 🤔

    Will try the short program when I get the chance and let you know

    Thank you for help

    Good to know what I am doing should work

    Yes processor and TX RX are right
    With a dropper circuit for the 3v3 levels

    Not scoped yet but good call 👍

    Andy

  5. #5
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,624


    Did you find this post helpful? Yes | No

    Default Re: Hersin quick question

    Hi Andy,
    Which PIC are you targeting (wondering if it's got an USART or EUSART)?
    My guess is that there's something weird going on with the baudrate.
    If possible, replace the Bluetooth connection with cable or, at the very least, verify with scope/logic analyzer that the data you send gets to the PIC and does ineed do so at the expected 9600 baud.

  6. #6
    Join Date
    May 2012
    Location
    Merseyside, UK
    Posts
    237


    Did you find this post helpful? Yes | No

    Default Re: Hersin quick question

    Sorry it is a 16f628A

    Will check in the next few days

    Thank you for all help so far

    Andy

  7. #7
    Join Date
    Aug 2011
    Posts
    460


    Did you find this post helpful? Yes | No

    Default Re: Hersin quick question

    Code:
    TRISB=%00000001 'Make RB0 input
    For the 16F628A you're setting the RX input (RB1) to output mode.
    The datasheet says to set both bits TRISB.2 (RB2/TX) and TRISB.1 (RB1/RX).

  8. #8
    Join Date
    May 2012
    Location
    Merseyside, UK
    Posts
    237


    Did you find this post helpful? Yes | No

    Default Re: Hersin quick question

    Hi All

    OK I now have set :-

    TRISB=%00000111 As per Data sheet ...... Really thought that would cure my issue


    Stripped code back to :-

    Main:
    HSERIN 5000, timeout,[char]
    HSEROUT[char]
    Goto main

    Timeout:
    HSEROUT["Back to loop"]
    Goto Main

    Connecting Hyperterminal via a Max232 .....

    Still nothing ... Hyperterminal is outputting as if i link tx/rx on 5v side I see the echo

    Tried different 16f628A...

    I am suspecting a config issue ..... As I can output directly to Hyperterminal OK :-

    DEFINE OSC 8
    DEFINE HSER_TXSTA 24H
    DEFINE HSER_RCSTA 90H
    DEFINE HSER_BAUD 9615
    DEFINE HSER_CLROERR 1

    '76543210
    TRISA=%00000010 'Make RA1 input
    TRISB=%00000111 'Make RB0 input and set RX/TX
    PORTA=%00000000 'Port A all low
    PORTB=%00000000 'Port B all low

    CMCON=7

    HSEROUT["This is a test"] ' Works fine

    Help..... :-)

    Andy

Similar Threads

  1. quick question
    By peterdeco1 in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 13th November 2016, 20:02
  2. A quick question.....
    By Megahertz in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 17th December 2010, 15:25
  3. Quick DS18B20 question
    By gti_uk in forum General
    Replies: 4
    Last Post: - 21st June 2009, 18:24
  4. quick question
    By Srigopal007 in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 2nd December 2004, 02:45

Members who have read this thread : 0

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

Tags for this Thread

Posting Permissions

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