serial trouble


Closed Thread
Results 1 to 8 of 8

Thread: serial trouble

  1. #1
    Join Date
    Dec 2003
    Location
    Storrs, Ct.
    Posts
    91

    Unhappy serial trouble

    I've tried several things but the problem is still unresolved.
    I am receiving serial with this command:

    SerIn2 PORTA.0, 84, 100, loop, [rtcday] 'put day byte in rtcday


    That works perfectly.
    When I try:

    SerIn2 PORTC.7, 84, 100, loop, [rtcday] 'put day byte in rtcday

    I get nothing.
    I've tried HSERIN also to no avail.

    As usual it's probably something simple. I've read many previous posts about serin2 and havn't seen the answer.

    Any comments would be appreciated.
    Thanks in advance for any help....


    16f876, PBP, 4mhz

  2. #2
    Join Date
    Nov 2004
    Location
    Fribourg, Switzerland
    Posts
    9


    Did you find this post helpful? Yes | No

    Default

    Hi Ronjodu,

    You didn't post all your code but as the 16F876 is analog input on PORT A and all MCU with analog input comes up in analog mode you have to set it to digital before using it.

    Try to add in the begin of your code:

    ADCON1=7

    I hope this solve your problem.

    Hans

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


    Did you find this post helpful? Yes | No

    Default

    SerIn2 PORTC.7, 84, 100, loop, [rtcday] 'put day byte in rtcday

    I get nothing.
    I've tried HSERIN also to no avail.


    solution is simple. You're using 4MHZ crystal to run 9600 baud.. it will not working properly. You must use higher speed crystal (20Mhz) or lowest baudrate (2400 baud).

    if you're using 20MHZ crystal don't forget in add
    DEFINE OSC 20

    and program your chip to HS oscillator mode.

    regards

    P.S. HSERIN work as inverted signal, must use transistor or MAX232 to invert signal.
    Steve

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

  4. #4
    Join Date
    Dec 2003
    Location
    Storrs, Ct.
    Posts
    91


    Did you find this post helpful? Yes | No

    Thumbs down serial trouble

    Thanks hmr and Mister_E for the response. I did have ADCON1 = 7 already. As I mentioned the serin2 worked when on PORTA.0.

    I assumed that I would only need to change the port address to PORTC.7 and all would work the same as if I had it on PORTA.0..

    I did try changing the baud to 2400 on the send (Siteplayer) and the receive(PIC) sides.

    To do this I changed the Siteplayer baud to:
    (Baud dw 65015 ( for those who might know siteplayer))
    And the pic command to:
    SerIn2 PORTC.7, 396, 100, loop, [decdate]

    Still no luck.
    I have a pulldown 2.2K resistor on the Siteplayer transmit line. This doesn't seem to bother the PORTA.0 receive.

    I'm open to all suggestions.
    Thanks again all...

    I'm editing this post because I have made some progress..
    It seems Siteplayer didn't change it's baud rate as I expected. I now have 2400 Xmit and Receive on both sides.
    I am getting data however it is not accurate. The numbers coming thru are wacked.

    Last edited by ronjodu; - 23rd November 2004 at 00:09.

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


    Did you find this post helpful? Yes | No

    Default

    what about if you remove TimeOut label???
    what about if you try an pullup instead???

    Are you sure voltage swing is correct for serial data. What about if you place an buffer between PIC and SitePlayer

    One thing is weird here.... work on PORTA not on PORTC... by a pure guess did you declare

    TRISC=255 ;portc as input???

    since PORTC is multiplexed with a load of peripheral function, it seems that is safe to do it. As a safe i always declare I/o directions..

    what about if you use SERIN or HSERIN without any timeout instead of SERIN2???
    Steve

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

  6. #6
    Join Date
    Dec 2003
    Location
    Storrs, Ct.
    Posts
    91


    Did you find this post helpful? Yes | No

    Default

    I have declared the following:

    TRISA = %00111111 'Set PORTA RA0-RA5 to input
    TRISB = %00000000 'Set PORTB to all output
    PORTB = %00000000 'Set all outputs to 0 (off)
    TRISC = %10000000 'Set PORTC to all output except #7
    PORTC = %00000000 'Set all outputs to 0 (off)

    I've tried serin and hserin but maybe the baud change will help. I'll try again in a bit. (Kid's hockey practice for now.)
    Probably the only hockey I'll see this year!!!

    Thanks again for the input...

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


    Did you find this post helpful? Yes | No

    Default

    not sure but if you declare
    TRISC = %10000000 'Set PORTC to all output except #7
    PORTC = %00000000 'Set all outputs to 0 (off)


    PORTC=%00000000
    will make PORTC.7 as output.... not sure of this. Try to remove PORTC= line.

    if data if wacked, maybe because of the Timeout label.

    regards
    Last edited by mister_e; - 23rd November 2004 at 02:11.
    Steve

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

  8. #8
    Join Date
    Dec 2003
    Location
    Storrs, Ct.
    Posts
    91


    Did you find this post helpful? Yes | No

    Default

    Hello again, sorry for the delay. Busy Holiday, no time.
    I've tried removing the timeout, no change. I did notice the data I was sending to the LCD was double what I expected.
    In other words I expect :
    "11/28/04" but got "22/56/08".

    I am now dividing the variable by 2 before sending to the LCD.

    The LCD now displays what I expect.

    My Question! Why, when I use:
    SerIn2 PORTA.0, 396, [decday]
    It works but when I use :
    SerIn2 PORTC.7,396,[decday]
    I have to divide the variable by 2?

    I've included my code. Go easy on me it's one of my first projects.
    Attached Files Attached Files
    Last edited by ronjodu; - 28th November 2004 at 23:31.

Similar Threads

  1. Replies: 33
    Last Post: - 19th March 2010, 03:02
  2. Dynamic USB Serial Number (PIC18F4550)
    By awmt102 in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 16th July 2009, 17:03
  3. PIC18F4680 to PC via MAX232 (RS232 serial) no output
    By opticsteam1 in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 14th April 2008, 20:39
  4. interfacing to the pc serial port
    By kelangfei in forum General
    Replies: 4
    Last Post: - 7th October 2007, 22:35
  5. Serious Serial Situation Setbacks...
    By Dansdog in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 7th February 2007, 03: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