2nd hardware UART


Results 1 to 28 of 28

Threaded View

  1. #12
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,615


    Did you find this post helpful? Yes | No

    Default Re: 2nd hardware UART

    In my experience the PBP HSER Defines doesn't generate any output (ie ASM code) code unless there's also a HSEROUT statement in the code - which seem to match what you're seeing. So you can't use the DEFINE directive to configure the UART unless you're also using HSEROUT.

    The fact that you CAN spoonfeed the UART and get data out means you DO have PPS and the UART itself configured properly so HSEROUT2 "should" work. Like I said, I've successfully done it on a K40 series so it must be something specific to this device or device series.

    And....looking at the generated code for HSEROUT2 on a K83 here's part of it:
    Code:
    000004                02884 HSEROUT2 ;movlb 15              ; Set bank select to 15 to pick up any SFRs not in Access bank
    000004 0139           02885         banksel  PIR6            ; Set bank for PIR3
    000006 0004               M         clrwdt
    000008 ABA6           02887         btfss   PIR6, U2TXIF    ; Wait till ready
    00000A D7FD           02888         bra     hserout2loop
    00000C 013D           02913         banksel  U2TXB           ; Set bank for TXREG2
    00000E 6FD2           02914         movwf   U2TXB          ; Send the char
    000010 80D8           02915         bsf     STATUS, C       ; Set no timeout for Serout2mod
    000012 EF0B F000      02916         goto    DUNN            ; That's it
    U2TXIF has the value of 5 which is correct (U2TXIF is bit 5 in the register) but it's looking at bit 5 in PIR6 which is wrong. U2TXIF is in PIR7.

    At this point I'm not sure where the actual error comes from and if it's something you or me can fix by simply editing a file or if it's buried in the exectuable of the compiler.

    /Henrik.

    EDIT: I think the compiler is using the pbp_pic18FxxK42.lib library file when compiling for the K83 as well because in IT is the reference to PIR6 in the HSEROUT2 function (and HSERIN2 as well) which, for the K42, is correct. For K83 it is not.

    I guess we can bodge this by editing the K42.lib file but then it won't work for K42 devices so, yeah... :-(
    Last edited by HenrikOlsson; - 14th August 2024 at 10:55.

Similar Threads

  1. PID-filter routine (2nd try).
    By HenrikOlsson in forum Code Examples
    Replies: 131
    Last Post: - 3rd October 2018, 07:53
  2. Setup baudrate on hardware uart on 18F4520
    By Pedro Pinto in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 25th August 2010, 00:31
  3. crucial error in a 90% working hardware uart
    By mimmmis in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 23rd September 2008, 14:18
  4. Serial Port Complete 2nd Edition
    By Bruce in forum Serial
    Replies: 4
    Last Post: - 8th November 2007, 15:28
  5. 2nd Order Digital Filter for 24-bit
    By sefayil in forum mel PIC BASIC
    Replies: 0
    Last Post: - 2nd December 2005, 21:55

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