Menu

More Serial RX problems

Rich
2023-12-10
2024-01-02
1 2 > >> (Page 1 of 2)
  • Rich

    Rich - 2023-12-10

    Hi Everyone,
    I'm a hobbyist learning GCBasic for the fun of it. I'm trying to achieve communication over the hardware serial port of a PIC16F1825. I seem to have it working OK when the PIC is transmitting but I can't get the PIC to receive anything. I've searched the forums but just can't seem to get this working. I've attached my working TX file and my non-working RX file. Any help much appreciated.

     
  • Anobium

    Anobium - 2023-12-10

    Hello,

    Have a look at the attached. These are very basic. You really need a recieve ring buffer else you will loose bits when you are displaying the bytes that have arrived.

    There is a ring buffer in the Help and in the demos.


    You had a bit of extra code in the programs. I have removed - it will be obvious.

    :-)

     
  • Anobium

    Anobium - 2023-12-10

    Attached is a ring buffer version. I just cut and pasted from the Help.

    Should work if you connect TX to RX, and RX to TX between the chips, with a common 0v0


    You typically do not need to configure the OSC, or, many of the registers that are document. GCBASIC does a lot for you. Just ask if you need more information.

     
  • Rich

    Rich - 2023-12-10

    Hi Anobium,
    Thanks for the quick reply. I found that I needed the register configurations for the TX program to work. If I leave them out then I get nothing. I tried your RXSerialComms file (thanks very much) but unfortunately I get nothing from that either. I am just using 1 chip connected to a PC terminal through a TTL adapter.

     
  • Anobium

    Anobium - 2023-12-10

    Which pin(s) to have connected? you should be using the default pins as detailed in the datasheet Table 1 RC4 and RC5.

     
  • Rich

    Rich - 2023-12-10

    Hmm. I'm using RA0 and RA1. They are also labelled as TX and RX.

     
  • Anobium

    Anobium - 2023-12-10

    Yes, try the others they are default and the ports we test against.. Then, if they work... then you can move back, if needed.

     
  • Rich

    Rich - 2023-12-10

    I tried the TX program that you modified on pins RC4 and RC5. I've attached a screenshot.

     
    • Anobium

      Anobium - 2023-12-10

      Do you have the PIC attached via a USB/TTL? You would need to invest the signal using a USB/TTL which you would not need between two pics.

       
  • Rich

    Rich - 2023-12-10

    Yes, I'm using a USB/TTL. I had the line SCKP=1 in my original file. I believe that this inverts the signal. If I wanted to try on the other serial ports would I just use HSerGetNum InputChar,2?

     
    • Anobium

      Anobium - 2023-12-10

      I would get the basics working first.

       
  • Rich

    Rich - 2023-12-10

    Yes, sorry I'm jumping ahead. I'm going to have to leave it for a while now but I'll try to get it working on the default ports and report back afterwards. Thanks again for your help.

     
  • Jerry Messina

    Jerry Messina - 2023-12-10

    You would need to invert the signal using a USB/TTL which you would not need between two pics.

    The signals of a USB-TTL UART cable should be exactly the same as a PIC UART, so no inversions should be required.

     

    Last edit: Jerry Messina 2023-12-10
  • Rich

    Rich - 2023-12-10

    Hi Jerry,
    I tried adding SCKP=1 back into the file supplied by Anobium. It make no difference whatsoever. I still get the output shown in the screenshot TX.jpg above.

     
  • Jerry Messina

    Jerry Messina - 2023-12-11

    I'm not aware of any USB-UART adapter that would require inverting the data, but if you do add 'SCKP=1' and the output doesn't change I don't know what to say. That instruction gets executed after the uart is set up, so it should definitely invert the output.

    Are you sure you have putty set for 9600 N81 with no handshaking?

     
  • Rich

    Rich - 2023-12-11

    I know that Putty is set correctly. The TX file in post 1 works perfectly using ports RA0 and RA1. I haven't altered any Putty settings between trying the different files.

     
  • Anobium

    Anobium - 2023-12-11

    Tested here and all looks good. See attached.

    So, I need the top section of the ASM file. It will look like this, or, something similar.

    This will tell me about your toolchain environment. Once we have this understood then we can look at the connectivity. A bad toolchain will generate an invalid HEX, so, we need to rule this out.

    ;Program compiled by GCBASIC (1.01.00 2023-11-28 (Windows 64 bit) : Build 1310) for Microchip MPASM/MPLAB-X Assembler using FreeBASIC 1.07.1/2023-12-10 CRC29
    ;Need help? 
    ;  See the GCBASIC forums at http://sourceforge.net/projects/gcbasic/forums,
    ;  Check the documentation and Help at http://gcbasic.sourceforge.net/help/,
    ;or, email us:
    ;   w_cholmondeley at users dot sourceforge dot net
    ;   evanvennn at users dot sourceforge dot net
    ;********************************************************************************
    ;   Source file    : C:\Users\admin\Downloads\TXSerialComms.gcb
    ;   Setting file   : C:\GCstudio\gcbasic\use.ini
    ;   Preserve mode  : 2
    ;   Assembler      : c:\microchip\mpasmx\mpasmx.exe
    ;   Programmer     : C:\GCstudio\gcbasic\..\PICKitPlus\PICKitCommandline.exe
    ;   Output file    : C:\Users\admin\Downloads\TXSerialComms.asm
    ;********************************************************************************
    
     
  • Jerry Messina

    Jerry Messina - 2023-12-11

    The TX file in post 1 works perfectly using ports RA0 and RA1

    Just to be clear, you're saying that with 'SCKP = 1' added to your file then you can see the TX output just fine on the terminal?

    What's the make and model of your USB adapter?

     
  • Rich

    Rich - 2023-12-12

    @evanvennn

    ;Program compiled by GCBASIC (1.01.00 2023-11-23 (Windows 64 bit) : Build 1308) for Microchip MPASM/MPLAB-X Assembler using FreeBASIC 1.07.1/2023-11-25 CRC29
    ;Need help?
    ; See the GCBASIC forums at http://sourceforge.net/projects/gcbasic/forums,
    ; Check the documentation and Help at http://gcbasic.sourceforge.net/help/,
    ;or, email us:
    ; w_cholmondeley at users dot sourceforge dot net
    ; evanvennn at users dot sourceforge dot net
    ;***********
    ; Source file : C:\Users\Rich\Desktop\O3 New Project\SerialComms\TXSerialComms.gcb
    ; Setting file : C:\GCstudio\gcbasic\use.ini
    ; Preserve mode : 0
    ; Assembler : GCASM
    ; Programmer :
    ; Output file : C:\Users\Rich\Desktop\O3 New Project\SerialComms\TXSerialComms.asm
    ;
    ***********

    My programmer is a Pickit3 but isn't set up in GCStudio.

    @Jerry Messina

    The first image shows SCKP = 1 running the TX code from post 1. The second shows with SCKP commented out. I don't know the make and model of the USB/TTL. Probably just a generic one from China. It is labelled MH on the rear. It is shown in the third image.

     
    • Anobium

      Anobium - 2023-12-13

      @Rich

      Thanks for the ASM header.

      You are up to date. I can tell that your are using an external programmer, that you do not have comments enabled in the ASM produced. you are using GCASM the internal assembler, and, most importantly you are using USE.INI to control your compilation.

      The tool chain all looks good.


      The issue is likely to be else where. @Jerry is leading that conversation. :-)

       
  • Rich

    Rich - 2023-12-12

    Images 1 and 2 should be reversed above.

     
  • Jerry Messina

    Jerry Messina - 2023-12-12

    Ok, Rich. So you have a USB-RS232 adapter along with a MAX3232 converter board to turn the RS232 into TTL levels.

    What's powering the MAX3232 converter board? There doesn't seem to be a connection shown to the board's VCC pin. Normally that would have to be 5V or 3V3.

     
  • Rich

    Rich - 2023-12-13

    What's powering the MAX3232 converter board? There doesn't seem to be a connection shown to the board's VCC pin. Normally that would have to be 5V or 3V3.

    The board is powered by the PC through the USB port.

     
  • Jerry Messina

    Jerry Messina - 2023-12-13

    Are you sure? Most of the MAX3232 boards I've seen require connecting external power to the VCC pin.

    I keep harping on this because that 'SCKP = 1' shouldn't be needed. There's something funny going on somewhere.

     
    • Awais

      Awais - 2023-12-13

      I agree with Jerry. Many years back I made this RS-232 converter using DIP package and this IC needs external 5V or 3.3V supply voltage. Pay attention for common "0 Volt". I think there is power indicator led D1 also on the module. Is it ON?
      Rich, in your posted photo "VCC" pin is not connected.

      Check Figure-1 in the following link.
      https://forum.arduino.cc/t/reading-rs232-with-max3232-module/911558/5

      Regards,
      Awais

       
1 2 > >> (Page 1 of 2)

Log in to post a comment.