Pic does not respond to SERIN: Serial I/O expander project


Closed Thread
Results 1 to 9 of 9

Hybrid View

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

    Default Re: Pic does not respond to SERIN: Serial I/O expander project

    Hi,
    Did you try without the spaces, ie #254#1#1?

    If you created a loopback you should be able to see what you send - as long as you send normal ASCII text like you initially did. When you type 254 and press send you should see 254 being "looped back" but when type #254 and press send you should NOT expect to see 254 being looped back because now a single byte with the value of 254 gets sent and 254 is non standard ASCII code so you'll get a weird character on the screen.

    Try this with your loopback:
    1) Type ABCD then press send (or enter).
    2) Type #65#66#67#68 then press send (or enter).

    What do you see? Now Google for ASCII chart or look in the back of the PBP manual, what does 65 correspond to?

    If skipping the spaces doesn't work then try modifying your PIC code so that, instead of 254, it waits for 65 or "A". By now you'd know that they are exactly the same thing. The value 65 is the ASCII code for the letter A. When you type A and press send the PC sends one byte out, that byte contains the value 65 of which when looped back to the PC gets displayed as A because that what's the value 65 represents.

    /Henrik.

  2. #2
    Join Date
    Feb 2006
    Posts
    10

    Default Re: Pic does not respond to SERIN: Serial I/O expander project

    Great explanation Henrik, thanks. Sounds absolutely logical. Unfortunately... still not working.

    I've modified the code to look for 65 as you suggested (see below). When I type #65#49#49 (49 would be ASCII for the number 1 which I'd like loaded into each of the variables, though for this exercise it obviously doesn't matter much) I see A11 in the loopback window. But... nothing happening on the PIC. Hmmmm.....

    Code:
    INCLUDE "bs2defs.bas"relay   VAR	b3 'relay number storage variable
    stat    VAR	b4 'relay status ON/OFF variable
    serpin  VAR	porta.4 'serial input pin
    trisa 	=	%00010000
    trisb 	=	%00000000
    
    
    High 0
    pause 100
    Low 0
    Pause 200
    High 0
    Pause 300
    Low 0
    
    
    loop:
      SERIN serpin,N2400,[65],relay,stat 'serial data in on PortA.4
      High 0
      pause 500
      low 0
      pause 200
      high 0
      pause 500
      low 0
      GOTO loop

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

    Default Re: Pic does not respond to SERIN: Serial I/O expander project

    Hi,
    Currently I can only think of three things:

    1) I don't see a DEFINE OSC in your code - are you using 4Mhz?
    2) PortA.4 is multiplexed with AN4 (analog input). Try adding ADCON1=7 to enable the digital input buffers on ALL analog inputs.
    3) You have the code set for 2400 baud, did you set the terminal up for that as well?

    Like you say, for this exercise it doesn't matter (since the PIC doesn't react at all) but with #65#49#49 the variables won't be loaded with 1 but with 49 since that's what your sending. To load them with 1 you'd do #65#1#1.

    /Henrik.

  4. #4
    Join Date
    Feb 2006
    Posts
    10

    Default Re: Pic does not respond to SERIN: Serial I/O expander project

    Henrik!! Yes! Thank you! The ADCON1=7 addition did the trick.

    thank you so much, you turned a bad day that was getting worse into a good one!

    best,
    Brad

Members who have read this thread : 0

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