XC8 software USART library?

Discussion in 'Embedded Systems and Microcontrollers' started by spinnaker, Oct 18, 2015.

  1. spinnaker

    Thread Starter AAC Fanatic!

    Oct 29, 2009
    4,887
    1,019
    I would like to make a full binary out port available to be able to quickly output a full byte of data.

    My problem is that the only full port I have also has a hardware serial I/O. I need serial I/O to communicate to TTY software on the PC.

    One thought I had was to use the software library. I could have sworn there was an implementation for it on one of Microchip's compilers. But I am using XC8. I check the docs and all I am seeing is the hardware implementation. Is the software version still supported?

    FYI: I will be using external interrupts and timer interrupts. Will I have an issue with software USART with interrupts.

    I do have one other serial port available but it is being used for SPI. I could share it but I imagine it would get real messy building chip select circuit (the devices I am using do not have their own) and have to reconfigure the port every time I want to use it for the different devices.
     
  2. joeyd999

    AAC Fanatic!

    Jun 6, 2011
    2,693
    2,765
    Yes. You will need to disable interrupts during transmission/reception. UART is finicky about timing.
     
  3. spinnaker

    Thread Starter AAC Fanatic!

    Oct 29, 2009
    4,887
    1,019
    If I use the hardware library I should not have a problem with interrupts correct?

    Where is the software library documentation?

    How would I know when to disable interrupts when the user is pressing a key on the keyboard? Currently I poll the serial in buffer. Should I be using interrupts there too?
     
  4. joeyd999

    AAC Fanatic!

    Jun 6, 2011
    2,693
    2,765
    Since I write .asm, I have no idea where you should look for library docs.

    With a hardware interrupt driven (E)U(S)ART, there is no issue with other interrupts.

    You must manually capture the start pulse with a software UART, though, and it needs to be done on a timely basis. Not that I've ever implemented one, but it seems that you'd pretty much have to constantly poll the receiver pin in main(), not leaving much time for anything else.

    On the other hand, you could make one of your external ints the RX pin, and trigger an interrupt on the falling edge of the start pulse. Then, processes the byte manually in the ISR. This will satisfy the timing requirement (and help with bit time alignment) at the expense of locking up your program for the duration of the byte(s).

    Edit: Oh, and while I can write C, I'd have no idea how to get the timing correct using C constructs. I'd probably wind up inlining .asm code.
     
  5. GopherT

    AAC Fanatic!

    Nov 23, 2012
    6,073
    3,856
    And that doesn't seem to be very convenient in the XC8 compiler. Easier formatting on the higher bit compilers for some reason. Stick with .asm.

    What compiler do you use to convert .asm to hex?.
     
Loading...