SEROUT,HSEROUT or DEBUG ? max 232 or no max232 ?


Closed Thread
Results 1 to 28 of 28

Hybrid View

  1. #1

    Default SEROUT,HSEROUT or DEBUG ? max 232 or no max232 ?

    I currently have my PC's serial port ready to send and receive to the PIC 18F4520....
    I have a max232n connected and have connected the pic to the correct pins on the max232n.
    I would like to receive the data in hyperterminal.
    BUT would also like to experiment with HSEROUT and DEBUG etc

    SO here are the questions.

    Of the following choices SEROUT,HSEROUT or DEBUG which one do I choose
    1.To communicate between two pics

    2.From PC to PIC which one should I choose in the following instances
    A.Without a max232n
    B.With a max232n


    3.From PIC to RF

    4.From PIC to IR

    For all the above when may I use the internal oscillator and when not ?

    And lastly ....
    Assuming the Port I would like to transmit/send the data out of is PORT C6
    and the receiving port is PORT C 7,
    would the line be something like
    Code:
    Loop:
    SerOut PinNumber,T2400,DataOut
    Pause 100 'Delay for Receive viewing
    goto Loop

  2. #2
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Dennis View Post
    Of the following choices SEROUT,HSEROUT or DEBUG which one do I choose
    1.To communicate between two pics
    SEROUT,SEROUT2,HSEROUT
    2.From PC to PIC which one should I choose in the following instances
    A.Without a max232n
    B.With a max232n
    A.Without a max232n
    SEROUT,SEROUT2,DEBUG
    B.With a max232n
    ANY
    3.From PIC to RF

    4.From PIC to IR
    ANY
    For all the above when may I use the internal oscillator and when not ?
    Bauds 4800 and below most times
    And lastly ....
    Assuming the Port I would like to transmit/send the data out of is PORT C6
    and the receiving port is PORT C 7,
    would the line be something like
    Code:
    Loop:
    SerOut PinNumber,T2400,DataOut
    Pause 100 'Delay for Receive viewing
    goto Loop
    Looks OK
    Dave
    Always wear safety glasses while programming.

  3. #3


    Did you find this post helpful? Yes | No

    Default It's working :-)

    Thanks a million DAVE

    Now trying out SEROUT and it's working like a charm :-)

    You answers have cleared up the confusion !

    Once again THANK YOU

    Keep well

    kind regards

    Dennis

  4. #4


    Did you find this post helpful? Yes | No

    Default Passsing the variable :-(

    So far I have tested ..SEROUT,SEROUT2 and DEBUG

    I just have an issue with somehow passing a variable around in my code it seems using SEROUT,SEROUT2 and DEBUG.

    So far I can capture a keypress (thanks to mister e's matrix keypad routine and advice and tips from several others - thank you!)
    The keypress from the keypad is stored in a variable called myvar.
    I send myvar to the LCD using
    Code:
    lcdout dec myvar      'display keypress variable
    and on the LCD the DECimal number lets say I press 1 on the keypad appears as ||1 and for the number 2 on keypad it appears as ||2 and so on.
    If I change the code to convert myvar as BINary numbers like this
    Code:
    lcdout BIN myvar      'display keypress variable
    then when I press the number 1 on the keypad I get ||1 on the LCD and then the keypad 2 shows as ||2 and so on.
    NOW .....
    If I use serout to send myvar to hyperterminal or MicroStudio serial port window like this
    Code:
    SerOut PORTC.6,T2400,["the key pressed is",myvar]
    I just get "the key is pressed' followed by a windings kinda characters like smileys, blocks and so forth :-(

    If I send a string with serout like this
    Code:
    SerOut PORTC.6,T2400,["the key pressed is"]
    Then everytime I press a key I see "the key is pressed" appearing in hyperterminal.

    Here is my code ....I would really appreciated if someone could point me towards finding a solution as ultimately I would like to TX the binary keypress to be RX for another PIC

    Code:
    '*************************************
    'Keypress display on LCD and TX to wherever
    '*************************************
    
    'Ocsillator selections here
            OSCCON = $70            'Int CLK 8MHz
            OSCTUNE.6 = 1           'PLL 4x
            ADCON1= %00001111       '$0F = disable A/D converter
            cmcon   =   7 
            INTCON2.7 = 0     'switch pull-ups ON
    'END of oscillator selections
      'timer/oscillator defines 
            DEFINE OSC 32            '4x 8MHz
    'END of timer/oscillator defines
    
    'Port IO directions and presets for port pins begin here
    'TRISX = %76543210   << tris bit order numbering
    'TRISA = %11111111       'All pins are outputs
    '// Define port pins as inputs and outputs ...
            TRISA  = %00000000 'example only - TRISB = %00001111 ;Make B4-B7 outputs, B0-B3 inputs, 
            TRISB = %11111111  'for 4x4 keypad all input
            TRISC = %10000000
            TRISD = %00000000
            TRISE.0 = 0
            TRISE.1 = 0
            TRISE.2 = 0
    'End of Port IO directions and presets for port pins begin here
    
                       
    'variables begin here
            myvar var byte
            dataout var byte
    'end of variables
    
    'LCD defines begin here   
            DEFINE LCD_BITS 4 	'defines the number of data interface lines (4 or 8) 
            DEFINE LCD_DREG PORTD 	'defines the port where data lines are connected to
            DEFINE LCD_DBIT 4 	'defines the position of data lines for 4-bit interface (0 or 4)
            DEFINE LCD_RSREG PORTD 	'defines the port where RS line is connected to
            DEFINE LCD_RSBIT 2 	'defines the pin where RS line is connected to 
            DEFINE LCD_EREG PORTD 	'defines the port where E line is connected to 
            DEFINE LCD_EBIT 3 	'defines the pin where E line is connected 
            DEFINE LCD_RWREG 0 	'defines the port where R/W line is connected to (set to 0 if not used)
            DEFINE LCD_RWBIT 0 	'defines the pin where R/W line is connected to (set to 0 if not used)
            DEFINE LCD_COMMANDUS 2000 	'defines the delay after LCDOUT statement 
            DEFINE LCD_DATAUS 200 		'delay in micro seconds
    'END of LCD DEFINES
    
    'includes begin here
            INCLUDE "modedefs.bas"
            include "c:\pbp\samples\keypad.bas"
    'end of includes
    
    'Keypad code begins here
            DEFINE KEYPAD_ROW        4        ' 4 ROW keypad       
            DEFINE KEYPAD_ROW_PORT   PORTB    ' ROW port = PORTB
            DEFINE KEYPAD_ROW_BIT    0        ' ROW0 = PORTB.4
            DEFINE KEYPAD_COL        4        ' 4 COL keypad
            DEFINE KEYPAD_COL_PORT   PORTB    ' COL port = PORTB
            DEFINE KEYPAD_COL_BIT    4        ' COL0 = PORTB.0
            DEFINE KEYPAD_DEBOUNCEMS 200      ' debounce delay = 200 mSec
            DEFINE KEYPAD_AUTOREPEAT 1        ' use auto-repeat feature
    'end keypad code
    
    'Main code begins here       
    
            Pause 2000       ' Wait for LCD to startup
    start:
            'read keypress variable 
            @ READKEYPAD _myvar 
    
            lcdout $fe, 1        'clear lcd screen
             
            lcdout BIN myvar      'display keypress variable
            SerOut PORTC.6,T2400,["the key pressed is",myvar] 'SerOut PinNumber2,T2400,DataRec
            pause 1000
            lcdout $fe,1          'clear lcd screen
    goto start
    
    'End of all code
    Thank you

    Kind regards
    Dennis

  5. #5
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    Try
    N2400
    Dave
    Always wear safety glasses while programming.

  6. #6
    Join Date
    Dec 2007
    Location
    Finland
    Posts
    191


    Did you find this post helpful? Yes | No

    Post

    Dennis,

    Have you read this?
    Communications Example : PC to PIC bi-directional dialogue

    Thanks to Melanie! This helped me a lot when I did code, which communicated with PC.


    BR,
    -Gusse-

    Edit 1: I have used baud rate up to 38400 very successful. It might work even higher data rate (haven't try so far).
    Edit 2: Running on 16F876A with 10MHz crystal, haven't tested with PIC that has internal oscillator. 1k5 resistors between PC and PIC (TX & RX).
    Last edited by Gusse; - 21st November 2009 at 20:23.

  7. #7


    Did you find this post helpful? Yes | No

    Default Thanks Gusse

    Will definitely check it out and do the suggested tests :-)
    Thank you

  8. #8
    Join Date
    Mar 2017
    Posts
    6


    Did you find this post helpful? Yes | No

    Default Re: SEROUT,HSEROUT or DEBUG ? max 232 or no max232 ?

    Hi Dennis I'm brand new to the forum.
    I see your question about the usage of max232 is my question as well, I have built an interface with a Wi-Fi chip and asked them if I needed the MAX232 chip to stabilise the signal quality using the picbasic "SEROUT" function and showed them an oscilloscope image of the signal produced and they were very busy and answered with "device connect to Wi-Fi is RS232 interface, the MAX232 chip is needed but not if UART".Did you find out if the process is RS232 or UART ?Name:  BaudRate_9600_Inverted.jpg
Views: 843
Size:  219.8 KBName:  BaudRate_9600_NotInverted.jpg
Views: 790
Size:  220.6 KB

  9. #9
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default Re: SEROUT,HSEROUT or DEBUG ? max 232 or no max232 ?

    You replied to a seven year old thread... It would be best to start a new thread.

    When you start the new thread be sure to include the PIC you are using along with the WIFI module you are using. Without knowing this we would just be guessing about the best solution for you.
    Dave
    Always wear safety glasses while programming.

  10. #10
    Join Date
    Oct 2004
    Posts
    448


    Did you find this post helpful? Yes | No

    Default Re: SEROUT,HSEROUT or DEBUG ? max 232 or no max232 ?

    Hi,

    Can I assume your wifi device is a variation of the ESP8266? If so, you would NOT require a MAX chip between the PIC and the Wifi module. Serout, Hserout should work, as also debug (the last in mode 0).

    Only thing to remember is the Wifi module, depending on the version you have might not be 5 volt tolerant.

    Regards,

    Anand Dhuru

  11. #11
    Join Date
    Mar 2017
    Posts
    6


    Did you find this post helpful? Yes | No

    Default Re: SEROUT,HSEROUT or DEBUG ? max 232 or no max232 ?

    Hello ardhuru,
    I took mackrackit's advice and moved my quiry to http://www.picbasic.co.uk/forum/showthread.php?t=22510
    cheers

Similar Threads

  1. N-Bit_MATH
    By Darrel Taylor in forum Code Examples
    Replies: 38
    Last Post: - 16th December 2010, 14:48
  2. Wireless using debug.
    By polymer52 in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 18th January 2010, 14:53
  3. About USB
    By dias11 in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 3rd December 2009, 20:41
  4. debug not working with MPASM assempler
    By santamaria in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 4th March 2009, 07:51
  5. Data EEPROM gets clobbered during programming
    By BrianT in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 18th July 2008, 02:46

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