Ii think I'm cracking up RS232


+ Reply to Thread
Results 1 to 11 of 11

Thread: Ii think I'm cracking up RS2324369 days old

  1. #1
    pmcleod
    Guest pmcleod's Avatar

    0 Not allowed!

    Default Ii think I'm cracking up RS232

    having a play with RS232 and the hrsin/hrsout commands but getting nowhere.
    have a cuircuit set up in isis and the following code at the minute I'm using the virtual terminal on isis to talk to the PIC, but get very odd results, hitting a single numeric key in the terminal gives 2 or for some numbers 3 outputs but never the key I've hit. It's using the latest beta but I'm sure it's me not the compiler.

    Device 16f877a
    XTAL 8
    Dim loopvar As Byte
    ALL_DIGITAL true
    Output PORTB
    Output PORTC.6
    Input PORTC.7

    '4bit lcd declares
    Declare LCD_DTPIN PORTB.4
    Declare LCD_RSPIN PORTB.1
    Declare LCD_ENPIN PORTB.2
    Declare LCD_INTERFACE 4
    Declare LCD_LINES 2

    main:
    Cls

    HSERIAL_BAUD = 300 ' Set baud rate to 300

    HSERIAL_RCSTA = %10010000 ' Enable serial port and continuous receive
    HSERIAL_TXSTA = %10100000 ' Enable transmit and asynchronous mode
    HSERIAL_CLEAR = On ' Optionally clear the buffer before receiving
    Dim VAR1 As Byte
    Dim loop As Byte
    VAR1 = 0

    VAR1 = HRSin, {2000 , timeout} ' ' Receive a byte serially into VAR1

    Print At 2, 1, "PMC", Dec VAR1, " detected"
    DelayMS 2500

    HRSOut "VAR1= " , Dec VAR1 ' Display the decimal value of VAR1
    GoTo main

    Stop

    timeout: Print At 1,1, "Wait for Panel"
    DelayMS 1000

    GoTo main

Attention

This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

The advertisements we display are relevant to this web site and your browsing history

Please consider supporting us by disabling your ad blocker.


Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

If you can, please report issues in the forum area WebSite / Forum Issues


Thank you for your attention.

  • #2
    Maverick
    Guest Maverick's Avatar

    0 Not allowed!

    Default

    can't see much wrong right now ,, just got up

    But you should move your MAIN: label and CLS to after your dim loop as byte

    Code:
    Device 16f877a
    XTAL 8
    Dim loopvar As Byte
    ALL_DIGITAL true
    Output PORTB
    Output PORTC.6
    Input PORTC.7
    
    '4bit lcd declares
    Declare LCD_DTPIN PORTB.4
    Declare LCD_RSPIN PORTB.1
    Declare LCD_ENPIN PORTB.2
    Declare LCD_INTERFACE 4
    Declare LCD_LINES 2
    
    main:    <------- move these
    Cls
    
    HSERIAL_BAUD = 300 ' Set baud rate to 300
    
    HSERIAL_RCSTA = %10010000 ' Enable serial port and continuous receive
    HSERIAL_TXSTA = %10100000 ' Enable transmit and asynchronous mode
    HSERIAL_CLEAR = On ' Optionally clear the buffer before receiving
    Dim VAR1 As Byte
    Dim loop As Byte
    
    
    main: 
    Cls                    <----- here
    
    
    VAR1 = 0
    
    VAR1 = HRSin, {2000 , timeout} ' ' Receive a byte serially into VAR1
    
    Print At 2, 1, "PMC", Dec VAR1, " detected"
    DelayMS 2500
    
    HRSOut "VAR1= " , Dec VAR1 ' Display the decimal value of VAR1
    GoTo main
    
    Stop
    
    timeout: Print At 1,1, "Wait for Panel"
    DelayMS 1000
    
    GoTo main

    Also if no joy try setting TXSTA=%00100100 ($24 hex)

    I'll take another look when I wake up fully

  • Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  • #3
    Mark Rodgers
    Guest Mark Rodgers's Avatar

    0 Not allowed!

    Default

    Hello Pete, just as a thought do you have a virtual terminal(in ISIS) on each of the input and output, they will show you what is actually happening on the port.

  • Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  • #4
    Prolific Poster See_Mos's Avatar
    Join Date
    Feb 2004
    Posts
    1,299
    Thumbs Up
    Received: 17
    Given: 0
    Total Downloaded
    872.27 MB

    0 Not allowed!

    Default

    Do you have a MAX232 or other interface to the PIC?

    If not have a look at the end of HRSIN in the help file or in ISIS right click on the terminal, select properties and change RX?TX Polarity to the other polarity from where it is now.
    My RAM is failing

  • Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  • #5
    pmcleod
    Guest pmcleod's Avatar

    0 Not allowed!

    Default

    Quote Originally Posted by Mark Rodgers View Post
    Hello Pete, just as a thought do you have a virtual terminal(in ISIS) on each of the input and output, they will show you what is actually happening on the port.
    Yes I do, that's where the data is coming out odd.

  • Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  • #6
    pmcleod
    Guest pmcleod's Avatar

    0 Not allowed!

    Default

    Quote Originally Posted by See_Mos View Post
    Do you have a MAX232 or other interface to the PIC?

    If not have a look at the end of HRSIN in the help file or in ISIS right click on the terminal, select properties and change RX?TX Polarity to the other polarity from where it is now.
    Ah you may have it there, I'll be back in a moment

  • Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  • #7
    pmcleod
    Guest pmcleod's Avatar

    0 Not allowed!

    Default

    Quote Originally Posted by Maverick View Post
    can't see much wrong right now ,, just got up

    But you should move your MAIN: label and CLS to after your dim loop as byte




    Also if no joy try setting TXSTA=%00100100 ($24 hex)

    I'll take another look when I wake up fully
    thanks
    Tried the TXSTA mod and i no longer get garbage but i get nothing on the LCD and the echo back gives a * every time.
    What I have noticed is that it'sdisplaying on the first charachter rather thann wait for a non dicimal chasracter, which seems odd. perhaps there's something I'm not grasping about the hrsin comand

  • Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  • #8
    pmcleod
    Guest pmcleod's Avatar

    0 Not allowed!

    Default

    nope, I was sure that was it butI get exactly the same with the rxtx inverted (yes I do have a max232 in circuit. getting the same seem svery odd

  • Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  • #9
    Prolific Poster See_Mos's Avatar
    Join Date
    Feb 2004
    Posts
    1,299
    Thumbs Up
    Received: 17
    Given: 0
    Total Downloaded
    872.27 MB

    0 Not allowed!

    Default

    I changed the PIC to 18F452 so that I could run the code with my ISIS licence. I changed the Baud to 9600 as that is what I mostly use. I used the PIC18_ALCD_VHB from the Proton VHB folder. Without the MAX232 the TX/RX polarity is 'normal' and using the code modified by Mav' it works.
    My RAM is failing

  • Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  • #10
    pmcleod
    Guest pmcleod's Avatar

    0 Not allowed!

    Unhappy

    Quote Originally Posted by See_Mos View Post
    I changed the PIC to 18F452 so that I could run the code with my ISIS licence. I changed the Baud to 9600 as that is what I mostly use. I used the PIC18_ALCD_VHB from the Proton VHB folder. Without the MAX232 the TX/RX polarity is 'normal' and using the code modified by Mav' it works.
    thanks, i've spent all afternoon on this and getting nowhere fast, I've now tried the code in the beta manual, withg both the beta and release version, no joy. what I am getting is repeatable in that when it's waiting for serial in if I hit key 1 in virtual terminal I get 12 flashed then 240 on the lcd. if I hit key 2 I get 112 then 240, if I push key 3, I get 124 then 240 all numbers are displayed with a single space between them. looking at debug info in isis I see hitting key 1 puts 12 in var1, key2 112 etc, where it's getting the 240 from I have no idea.

    I've not tried 9600 baud but will go do so.

    cheers pete

  • Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  • #11
    pmcleod
    Guest pmcleod's Avatar

    0 Not allowed!

    Default

    Quote Originally Posted by See_Mos View Post
    I changed the PIC to 18F452 so that I could run the code with my ISIS licence. I changed the Baud to 9600 as that is what I mostly use. I used the PIC18_ALCD_VHB from the Proton VHB folder. Without the MAX232 the TX/RX polarity is 'normal' and using the code modified by Mav' it works.
    right some progress, Mav's code largly works but only at 9600 baud not at 300, so i guess something in either proton or labcentre doesn't like 300 baud. when I say largely works it does what it's told, I think, but not quite what I wanted, but some progress is being made.
    I'm going to bed now, having not gone to bed last night I need some kip.

    thanks all for the input, you're all great.

  • Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

    Thread Information

    Users Browsing this Thread

    There are currently 1 users browsing this thread. (0 members and 1 guests)

       

    Similar Threads

    1. Rs232
      By metwally in forum Absolute Beginners Section
      Replies: 11
      Last Post: 15th April 2013, 13:22
    2. Which RS232 IC?
      By pic-ignorant in forum The Lounge
      Replies: 9
      Last Post: 30th August 2010, 22:36
    3. Rs232
      By C_Moore in forum Proton Plus Compiler v3
      Replies: 10
      Last Post: 22nd May 2006, 18:23
    4. Why use RTS in RS232?
      By Pkirk in forum The Lounge
      Replies: 4
      Last Post: 5th March 2006, 21:41
    5. Rs232
      By mobyuk in forum The Lounge
      Replies: 1
      Last Post: 25th September 2003, 11:08

    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