Serin serout problem


Closed Thread
Results 1 to 40 of 337

Hybrid View

  1. #1
    Join Date
    Sep 2006
    Posts
    747


    Did you find this post helpful? Yes | No

    Default

    well basically I use this command:
    serin portB.2 = works
    serin portE.2 = do not work

    I set them both as input.
    All my B ports are taken up already.

  2. #2
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by lerameur View Post
    well basically I use this command:
    serin portB.2 = works
    serin portE.2 = do not work

    I set them both as input.
    All my B ports are taken up already.
    It's not set up as an analog port is it?
    Maybe you set TRISE as $FF instead of %00000111. If you did, bit 4 will change Port E into control for the PBP.
    But, again, I'm probably pointing out the obvious to you...
    Have you tried just setting the pin high and low and reading it and seeing what happens?

  3. #3
    Join Date
    Sep 2006
    Posts
    747


    Did you find this post helpful? Yes | No

    Default

    Well here is the program that works:
    but changing portb.2 to porte.2
    it do not work.


    INCLUDE "modedefs.bas"
    @ DEVICE PIC16F877a , HS_OSC , WDT_OFF , PWRT_ON , BOD_ON , LVP_OFF , PROTECT_OFF
    'HS 20mhz, watchdog off, powerup timer on, mclr external, brown out detect on, low volt program off , code protect off

    DEFINE OSC 20 'use external 20mhz crystal

    DEFINE LCD_DREG PORTD ' Set LCD Data port
    DEFINE LCD_DBIT 4 ' Set starting Data bit (0 or 4) if 4-bit bus
    DEFINE LCD_RSREG PORTC ' Set LCD Register Select port
    DEFINE LCD_RSBIT 6 ' Set LCD Register Select bit
    DEFINE LCD_EREG PORTC ' Set LCD Enable port
    DEFINE LCD_EBIT 7 ' Set LCD Enable bit ' Set LCD Enable bit
    DEFINE LCD_BITS 4 ' Set LCD bus size (4 or 8 bits)
    DEFINE LCD_LINES 2 ' Set number of lines on LCD
    DEFINE LCD_COMMANDUS 2500
    DEFINE LCD_DATAUS 250
    DEFINE CHAR_PACING 2000

    Pause 2000 ' Wait 2 second

    TRISA = %11111111 ' Set PORTA to all input
    TRISB = %00111111
    TRISC = %00010000
    TRISD = %00000000
    TRISE = %00000111

    right var byte : left var byte
    temp var word : counter var byte
    rightold var word : leftold var word : speedright var byte : speedleft var byte

    '************************************************* ***************************************
    loop:

    portb.7 =1
    pause 100
    portb.6 =1
    pause 100

    waitfor55:
    serin portb.2 , n2400 , temp : if temp <> $55 then goto waitfor55
    waitforaa:
    serin portb.2 , n2400 , temp : if temp <> $aa then goto waitforaa

    serin portb.2, n2400, rightold.LowBYTE : serin portb.2, n2400, rightold.HighBYTE
    serin portb.2, n2400, leftold.LowBYTE : serin portb.2, n2400, leftold.HighBYTE

    For counter=0 TO 7 'decoding
    right.0[counter]=rightold.0[counter*2]
    left.0[counter]=leftold.0[counter*2]
    Next counter
    Lcdout $fe, 1 'Clear screen
    Lcdout "Left: ", Dec left
    Lcdout $fe, $C0, "Right: ", Dec right
    Pause 100
    goto loop
    end
    Last edited by lerameur; - 6th February 2007 at 02:30.

  4. #4
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by lerameur View Post
    Well here is the program that works:
    but changing portb.2 to porte.2
    it do not work.
    Wow, that should work...
    How about e.0 or e.1? Do they work?

  5. #5
    Join Date
    Sep 2006
    Posts
    747


    Did you find this post helpful? Yes | No

    Default

    no does not work
    I tried other B port and they work.
    I tried the analog ports like porta.0 and does not work.
    Should all the analog ports be used just for analog ?

    k

  6. #6
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    Should all the analog ports be used just for analog ?
    Unless you disable the analog capability... yes

    As far as i remind of this chip PORTE<2:0> have multiplex analog stuff on that you have to disable first
    Code:
    ADCON1=7
    CMCON=7
    those will help... but better if you refer to the datasheet to make sure of everything.
    Last edited by mister_e; - 6th February 2007 at 03:48.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  7. #7
    Join Date
    Sep 2006
    Posts
    747


    Did you find this post helpful? Yes | No

    Default

    that would include port e too?
    I will need to use the analog port of portA later on too...
    wouldn't that disable them ? Or do I need to find anothe rport for my serin command ?
    I gues i have to play around with adcon (bit 0 to 3 )
    Last edited by lerameur; - 6th February 2007 at 03:57.

Similar Threads

  1. A Serial GLCD 128x64 Simple Project
    By Oldspring in forum Off Topic
    Replies: 0
    Last Post: - 8th March 2010, 20:58
  2. PIC16f877 code crosses boundary @800h
    By inventosrl in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 6th April 2009, 22:03
  3. serout and serin problem
    By nicolelawsc in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 11th April 2006, 19:44
  4. Replies: 11
    Last Post: - 13th July 2005, 19:26
  5. SerIn and SerOut
    By Dwayne in forum FAQ - Frequently Asked Questions
    Replies: 0
    Last Post: - 21st July 2004, 15:54

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