18f4520 serial communication


Closed Thread
Results 1 to 7 of 7
  1. #1
    Join Date
    Feb 2007
    Posts
    14

    Unhappy 18f4520 serial communication

    Hello,
    I am a newbie, sorry if this is a stupid question, but i can find anything on this issue. Trying to learn small programming at a time to pick it apart.
    I am wanting to experiment with serial communication with this chip. does anyone have an example of serial communication with the 18f4520.
    My circuit board uses portc.6 for tx and portc.7 for rx. I have tried the sample program and find that i can not get it to work.
    All i would like to do is transfer a text message to hyperterminal to see how data transfer works.
    I take it that is the program that i would use. I hear people talking about using Microcode to receive this, not sure about this.
    This is what i have at the moment.
    I would also like to see how receivinig data works too. Let say i hit a key and i get it back on the screen,Echo.

    include "modedefs.bas"


    CMCON = 7
    TRISC.7 = O
    PORTC.7 = 0

    print:
    Serout PORTC.7, N2400, ["test"] ' Send string
    pause 100 ' pause 1/10 sec
    Goto print ' Forever

    end

    Appreciate any help. I probably missed some type of configuration of the PIC chip but i think this is it.

    Thanks,
    Merlinknight

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


    Did you find this post helpful? Yes | No

    Default

    What's your crystal speed?

    For ANY PIC with a built-in USART (EUSART) i will suggest you to use it with a MAX232 inverter (or else). HSERIN/HSEROUT

    MicroCodeStudio Serial communicator work pretty well. In the IDE, just hit F4, set the right settings then hit F9 to connect on the selected COM port. Easy easy easy.
    Steve

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

  3. #3
    Join Date
    Feb 2007
    Posts
    14


    Did you find this post helpful? Yes | No

    Default

    Thanks Steve,
    It is connected to a MAX232 . OSC is at 4 mhz. didnt know about the serial communicator. Nice toy. Still learning. But not giving up.

    Thanks for taking the time to reply.

    Merlin Knight
    Last edited by merlinknight; - 4th March 2007 at 02:04.

  4. #4
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by merlinknight View Post
    Thanks Steve,
    It is connected to a MAX232 . OSC is at 4 mhz. didnt know about the serial communicator. Nice toy. Still learning. But not giving up.

    Thanks for taking the time to reply.

    Merlin Knight
    Didn't you say earlier you were using C.6 for TX and C.7 for RX?
    Your code says exactly the opposite...

    --> My circuit board uses portc.6 for tx and portc.7 for rx.

    --> Serout PORTC.7, N2400, ["test"] ' Send string

  5. #5
    Join Date
    Jul 2003
    Posts
    2,405


    Did you find this post helpful? Yes | No

    Default

    You need to use non-inverted serial mode if you're going through the max232.
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

  6. #6
    Join Date
    Feb 2007
    Posts
    14


    Did you find this post helpful? Yes | No

    Question

    ok, i did have the incorrect pin. Thank you
    second, i needed to change to T2400. Thank you

    I will try to review my work closer in the future. Didn't see these.

    It is now working. One more question.


    include "modedefs.bas"


    print:
    Serout PORTC.6, t2400, ["test"] ' Send string
    pause 100 ' pause 1/10 sec
    Goto print ' Forever

    end


    If i was to use this statement how would the con be stated? SO con PortC.6. It does not compile with this. What should be here. I would think that i need to state port and bit.

    SO con portc.6 ' Define serial out pin
    Last edited by merlinknight; - 4th March 2007 at 15:41.

  7. #7
    Join Date
    Jul 2003
    Posts
    2,405


    Did you find this post helpful? Yes | No

    Default

    PBP automatically makes the pin an output.

    Serout PORTC.6 tells PBP which port & pin to use. You can't declare a port
    pin as a constant.
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

Similar Threads

  1. Wireless serial communication question
    By Ahmadabuomar in forum Serial
    Replies: 3
    Last Post: - 21st December 2009, 03:49
  2. PIC to PIC "wired" serial one-way communication - SERIN2/SEROUT2
    By flotulopex in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 14th April 2008, 20:02
  3. Bootloader,MCSP and Serial communication
    By surfer0815 in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 3rd March 2006, 10:52
  4. Serial Communication using 12F629
    By charudatt in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 14th March 2005, 04:24
  5. Replies: 8
    Last Post: - 11th November 2004, 20:08

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