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


Closed Thread
Results 1 to 28 of 28

Hybrid View

  1. #1


    Did you find this post helpful? Yes | No

    Default :-)

    Darrel


    .'
    ?Is Steve mister e ??
    Code-wise I tried , Bruce's code and Trent Jackson's code ....
    Mister e's is what I'm using at the moment, it was the one that worked for me, but the other would probably work now that the LCD problem is cleared up ;-) ...

    Where is the keypad code you are referring to ? I am willing to give it a bash :-)

    Kind regards

    Dennis

    Oh and I sure did get my fair share of moving wires and resistors around to get the correct column and row assingments ;-)
    Roll on virtual ports hey ?
    Last edited by Dennis; - 22nd November 2009 at 01:09.

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


    Did you find this post helpful? Yes | No

    Default

    Yup, Steve is mister-e.

    By changing from key numbers to ASCII with the Lookup, your serout should work better.
    <br>
    DT

  3. #3


    Did you find this post helpful? Yes | No

    Default Thanks again ...

    Darrel :-)

    So with 8 sets of eyes in total now ... should I add the LOOKUP prior to making the assembly key lookup like this ?
    Code:
    start:
            'read keypress variable 
            @ READKEYPAD _myvar 
            LOOKUP  myvar,[0,"123A456B789C*0#D"],myvar
            'lcdout $fe, 1        'clear lcd screen
               'pause 2000
            lcdout dec myvar      'display keypress variable myvar
       
       'transmit section
            SerOut PORTC.6,T2400,["the key pressed is",myvar] 'SerOut PinNumber2,T2400,DataRec
            pause 1000
       'transmit section ends
            
        'receive section 
             'SerIn PORTC.7,T2400,DataRX       
             'LCDOUT datarx          'displays data received from serin datarx
        'receive section ends
            lcdout $fe,1          'clear lcd screen
            
    goto start
    Kind regards
    Dennis


    @ READKEYPAD _myvar

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


    Did you find this post helpful? Yes | No

    Default

    Except for the DEC modifier, good to go.

    Code:
    start:
            'read keypress variable 
            @ READKEYPAD _myvar 
            LOOKUP  myvar,[0,"123A456B789C*0#D"],myvar
            'lcdout $fe, 1        'clear lcd screen
               'pause 2000
            lcdout <strike>dec</strike> myvar      'display keypress variable myvar
       
       'transmit section
            SerOut PORTC.6,T2400,["the key pressed is",myvar] 'SerOut PinNumber2,T2400,DataRec
            pause 1000
       'transmit section ends
            
        'receive section 
             'SerIn PORTC.7,T2400,DataRX       
             'LCDOUT datarx          'displays data received from serin datarx
        'receive section ends
            lcdout $fe,1          'clear lcd screen
            
    goto start
    DT

  5. #5


    Did you find this post helpful? Yes | No

    Default I noticed...

    OK got your message after I tried with the DEC modifier ;-) nothing worked !
    So I removed it and .....
    The LCD now shows the correct characters as per what I type in 123 etc and the ABCD keys as well as # and * ....YAY.....
    but sadly now nothing appears in hyperterminal ....
    Does SEROUT now need to be replaced by SEROUT2 ?
    Will try it later and post results either way :-)
    Need some sleep now ..
    Thanks so much for your continued help :-) much appreciated !

    Keep well

    Kind regards
    Dennis

    OH .. by the way .. do you maybe know how I could capture a keyin of the number say 135 # so that it is actually stored as binary or decimal 135 ?

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


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Dennis View Post
    but sadly now nothing appears in hyperterminal ....
    Does SEROUT now need to be replaced by SEROUT2 ?
    If you have PBP 2.60 then that will help. SEROUT has a buad rate problem.

    OH .. by the way .. do you maybe know how I could capture a keyin of the number say 135 # so that it is actually stored as binary or decimal 135 ?
    If you have 2.60, it's real easy with ARRAYREAD.
    <br>
    DT

  7. #7


    Did you find this post helpful? Yes | No

    Default Solved!!

    Hi Darrel

    Problem seems to be solved now.

    And the solution was in the very problem itself ...passing the variable !!

    I created a new variable called datatx
    and then after the displaying myvar to LCD with LCDOUT,
    all I did was let datatrx = myvar
    then SEROUT myvar
    And whammo it works :-) YAY ...!

    Thanks so much for all your help !

    Here's the code for reference and for anyone who might find it useful
    It captures a keypress, diplays it on the LCD and send the captured keypress via SEROUT.

    Kind regards
    Dennis

    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
            datatx var byte
            datarx 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 
            LOOKUP  myvar,[0,"123A456B789C*0#D"],myvar
           
            'lcdout $fe, 1        'clear lcd screen
               'pause 2000
            lcdout myvar      'display keypress variable myvar
                 
                  datatx = myvar '<<<<here's the solution :-)
                 lcdout datatx
       'transmit section
    'THE PROBLEM LINE >>>        SerOut PORTC.6,T2400,["the key pressed is ",datatx] 
            SerOut PORTC.6,T2400,["the key pressed is ",datatx] 'SerOut PinNumber2,T2400,DataRec (FIXED!!
            pause 1000
       'transmit section ends
            
        'receive section 
             'SerIn PORTC.7,T2400,DataRX       
             'LCDOUT datarx          'displays data received from serin datarx
        'receive section ends
            lcdout $fe,1          'clear lcd screen
            
    goto start
    
    'End of all code

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 : 3

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