• AVR Freaks

Hot!TXIF Always Low

Author
pcamp510
New Member
  • Total Posts : 2
  • Reward points : 0
  • Joined: 2020/07/26 12:44:04
  • Location: 0
  • Status: offline
2020/07/27 19:45:51 (permalink)
0

TXIF Always Low

I am using a PIC18F67K40 and trying to get serial comms on UART1 and 2 (there might be a reference to UART5 in the code as well, I think in the interrupts, that was a test). I am watching the TX pins with a scope and see the pins go high (idle) on startup but cannot transmit data. The TXIF of port 1 and 2 does not go high.
 
The code as it stands will hang on line 136 of eusart2.c (waiting for PIR3bits.TX2IF to go high). We will sit here forever.
 
while(0 == PIR3bits.TX2IF)
    {
    }

 
If I force something into TX2REG it will sit there and not transmit.
 
 EDIT: The first two bites go into TSR and TXxREG fine. TXxIF only goes high after the second byte is transmitted in. Data still never gets transmitted out.
post edited by pcamp510 - 2020/08/01 18:22:00
#1

3 Replies Related Threads

    pcamp510
    New Member
    • Total Posts : 2
    • Reward points : 0
    • Joined: 2020/07/26 12:44:04
    • Location: 0
    • Status: offline
    Re: TXIF Always Low 2020/08/02 19:26:40 (permalink)
    +1 (1)
    I was under the impression that the baud rate is calculated from Fosc/4 but evidently that is not true. You must have the Peripheral System Clock enabled (PMD0.SYSCMD). 
    #2
    JPortici
    Super Member
    • Total Posts : 1153
    • Reward points : 0
    • Joined: 2012/11/17 06:27:45
    • Location: Grappaland
    • Status: offline
    Re: TXIF Always Low 2020/08/03 02:19:05 (permalink)
    +1 (1)
    At every reset ALL the PMD bits are cleared so the system clock is active.
    in the K40 series the Baud rate is calculated from FOSC, as the datasheet clearly says in the BRG section.
     
    I also suggest you re-read the Transmit interrupt section and if you are not going to use interrupts you're better off with the TMRT flag
    #3
    ric
    Super Member
    • Total Posts : 28299
    • Reward points : 0
    • Joined: 2003/11/07 12:41:26
    • Location: Australia, Melbourne
    • Status: online
    Re: TXIF Always Low 2020/08/03 03:03:59 (permalink)
    +1 (1)
    Jack_M
    I also suggest you re-read the Transmit interrupt section and if you are not going to use interrupts you're better off with the TMRT flag

    I would respectfully disagree.
    You don't need to enable TX interrupts, but it is still more efficient to poll the TXIF flag than the TRMT flag.
     

    I was under the impression that the baud rate is calculated from Fosc/4 but evidently that is not true. You must have the Peripheral System Clock enabled (PMD0.SYSCMD).

    The "Peripheral System Clock" is the same speed as Fosc, but as you've found, can be disabled to save power.
    The USART is a peripheral, so if you disable the peripheral clock, the USART has no clock.
     

    I also post at: PicForum
    Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
    NEW USERS: Posting images, links and code - workaround for restrictions.
    To get a useful answer, always state which PIC you are using!
    #4
    Jump to:
    © 2020 APG vNext Commercial Version 4.5