USART with INTERRUPTS


Closed Thread
Results 1 to 13 of 13

Hybrid View

  1. #1
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by crhomberg View Post
    Thanks for correcting my code but at 9600 baud (BRGH=31 for 20MHz)
    If you're using SEROUT2 to send characters back to the PC, you need to go back and read the PBP manual on how to use it. And, you have to set up a few more registers to get the UART receive port working correctly. Read the UART section in the datasheet for a bit and come back with your results...

    And which version of PBP are you using?

  2. #2
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    So, all you're really trying to do right now is get a 'loop back' to work?

    @ device hs_OSC, wdt_on, pwrt_on, protect_off
    define osc 20
    Include "modedefs.bas"
    trisc.6=0:trisc.7=1:trisd.0=0:serialdata var byte : counter var word : counter2 var word
    main:
    counter=counter+1 : portd.0 = counter.1 'toggle led on portd.0 each time thru the loop
    serialdata=0:serin portc.7, n9600, serialdata:if serialdata=0 then goto main 'get serial data, if none, restart loop
    counter2 = counter2 + 1:serout portc.6, n9600, [ dec counter2 , ":" , serialdata , 13 , 10 ]:goto main
    end
    Last edited by skimask; - 17th April 2007 at 19:08.

  3. #3
    Join Date
    Apr 2007
    Location
    Santiago, Chile
    Posts
    77


    Did you find this post helpful? Yes | No

    Unhappy USART Problems

    Thanks SkiMask,

    I have used and tested SEROUT2 many times without a hitch, it is sending test values just as I send them.
    As far as reading the USART manual, I have been reading it for the last 2 days.
    I am getting square eyes but seem to have missed something.

    You saw how I used SEROUT2 in my code (is it wrong?)

    Maybe I should just use HERIN instead

    Regards

    Chris

  4. #4
    Join Date
    Apr 2007
    Location
    Santiago, Chile
    Posts
    77


    Did you find this post helpful? Yes | No

    Unhappy USART Problems

    Yes, just a loopback

  5. #5
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by crhomberg View Post
    Yes, just a loopback
    See post 6. Are you using a max232 or the resistors like in the manual?

    AND WHICH VERSION OF PBP ARE YOU USING?

  6. #6
    Join Date
    Apr 2007
    Location
    Santiago, Chile
    Posts
    77


    Did you find this post helpful? Yes | No

    Default USART Problems

    I tried the tester as below (cut & paste except the range) but just a a list of ascii garbage. I am monitoring using the microcode studeo serial communicator and have tried receiving at various speeds.
    The output is via a 1K resistor.

    Regards

    Chris

    ´*********************************

    @ device hs_OSC, wdt_on, pwrt_on, protect_off
    define osc 20

    DEFINE HSER_RCSTA 90h ' Enable serial port & continuous receive
    DEFINE HSER_TXSTA 20h ' Enable transmit, BRGH = 0
    DEFINE HSER_SPBRG 64 ' 2400 Baud @ 4MHz, 0.17%
    DEFINE HSER_CLROERR 1 ' Clear overflow automatically

    Pause 500

    Start:
    FOR SPBRG=15 to 100
    HSEROUT ["SPBRG=",#SPBRG]
    PAUSE 50
    NEXT
    stop 'put this in to do it only once
    GOTO Start

  7. #7
    Join Date
    Apr 2007
    Location
    Santiago, Chile
    Posts
    77


    Did you find this post helpful? Yes | No

    Default USART Problems

    By the way,

    I am using PBP version 2.46

    Regards

    Chris

  8. #8
    Join Date
    Sep 2005
    Location
    Campbell, CA
    Posts
    1,107


    Did you find this post helpful? Yes | No

    Default

    If you are using HSERIN/HSEROUT, you can't simply use a resistor. The data is inverted compared to what it needs to be in order to communicate with any normal serial device (such as a PC).

    A MAX232 (or equivalent), not only changes the voltage swings and levels, it inverts the signals as well.
    Charles Linquist

Similar Threads

  1. Instant Interrupts - Revisited
    By Darrel Taylor in forum Code Examples
    Replies: 772
    Last Post: - 17th February 2016, 23:14
  2. Clock using Instant Interrupts
    By PICpocket in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 16th February 2009, 22:43
  3. DT's Instant Interrupts trouble
    By Tomexx in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 24th November 2008, 21:48
  4. help: TMR0 interrupts disabling PORTAchange interrupts???
    By xnihilo in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 19th August 2008, 16:10
  5. problem with USART
    By leemin in forum Serial
    Replies: 4
    Last Post: - 11th December 2006, 18:56

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