I ammm Looosssst (USART Help)


Closed Thread
Results 1 to 6 of 6

Hybrid View

  1. #1
    Join Date
    Dec 2004
    Location
    nebraska
    Posts
    79


    Did you find this post helpful? Yes | No

    Default

    This is the best I can come up with right now for a sample program. I am using 18f452 for the receiver and the transmiter. I want the receiver to use a PBP Interupt handler so that the microcontroller can do its thing and not half to wait idle for data from the transmiter.
    Transmiter code is :

    DEFINE LOADER_USED 1
    DEFINE OSC 4
    DEFINE HSER_RCSTA 90h ' enable serial port,
    ' enable continuous receive
    '
    define HSER_TXSTA 24h ' enable transmit,
    ' BRGH=1
    '
    define HSER_SPBRG 103 ' set baudrate to 2400
    DEFINE HSER_CLOERR 1 ' automatic clear overrun error

    TrisB.0 = 0

    Counter Var word
    DataIn Var Word
    DataOut Var Word

    Dataout = 10
    Counter = 0
    DataIn = 0



    Loop:
    PortB.0 = 1 'Led on
    hserout [DataOut] 'Serial Out PortC.6 Once every 5 seconds
    pause 3000
    PortB.0 = 0 'Led Off
    pause 2000
    GoTo Loop






    The Reciever code is:

    DEFINE LOADER_USED 1
    DEFINE OSC 4
    DEFINE HSER_RCSTA 90h ' enable serial port,
    ' enable continuous receive
    '
    define HSER_TXSTA 24h ' enable transmit,
    ' BRGH=1

    define HSER_SPBRG 103 ' set baudrate to 2400
    DEFINE HSER_CLOERR 1 ' automatic clear overrun error

    TrisB.0 = 0

    Counter Var word
    DataIn Var Word

    Counter = 0
    DataIn = 0

    on interrupt goto Reader

    'For Visual purposes to simulate doing something.
    'Flashing an LED on for half sec off for half sec.
    Main_Program:
    Counter = 0
    PortB.0 = 1
    While Counter < 500
    Counter = Counter + 1
    Pause 1
    wend
    Counter = 0
    PortB.0 = 0
    While Counter < 500
    Counter = Counter + 1
    Pause 1
    wend
    GoTo Main_program


    disable ' Disable interrupts
    Reader:
    rcsta.4 = 0 ' Clears Rx register overrun error,sets SREN off
    rcsta.4 = 1 ' Sets SREN on
    hserin [DataIn] 'PortC.7 serial In
    Serout PortB.1,6,[12,#DataIn] 'Display data on LCD
    pause 1000 'This pause should give a noticable
    'diference in Led flashing
    Serout PortB.1,6,[12] 'Clear LCD Display
    resume ' Leave interrupt routine
    enable

    Everything seems to be working except the reciever module never goes into the interupt routine. Also the Transmiter TX line seems to be always high. I came up with this test code from the PBP manual and many post here.
    Last edited by shawn; - 14th May 2006 at 03:59.

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


    Did you find this post helpful? Yes | No

    Default

    Steve

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

  3. #3
    Join Date
    Dec 2004
    Location
    nebraska
    Posts
    79


    Did you find this post helpful? Yes | No

    Default

    Thanks Steve
    That worked, I will probably have more questions but that defenitly gave me something to work with.

Similar Threads

  1. byte Tx w/ USART 16f876a problem
    By GargamelDigi in forum mel PIC BASIC
    Replies: 2
    Last Post: - 15th July 2008, 05:50
  2. Usart Questions
    By shawn in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 8th March 2008, 01:17
  3. problem with USART
    By leemin in forum Serial
    Replies: 4
    Last Post: - 11th December 2006, 17:56
  4. USART interrupt not interrupting right
    By Morpheus in forum mel PIC BASIC Pro
    Replies: 12
    Last Post: - 6th March 2005, 01:07
  5. Replies: 5
    Last Post: - 1st December 2004, 12:49

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