>
> No, what he's looking to do is keep it from actually turning off the
> transmission (ie, drop into receive mode) immediately after the last useful
> byte. The if TRMT bit generated an interrupt (somebody in Arizona listening?)
> then it would be a no-brainer. As it is, you have to wait for TXIF and TRMT to
> both be true, and the 400 instructions is how long that takes after sticking the
> last char into TXREG.
>
> Andy
>
> "M. Adam Davis" <
EraseMEadavisspam_OUT
TakeThisOuTUBASICS.COM> on 08/10/2000 01:14:52 PM
>
> Please respond to pic microcontroller discussion list <
PICLIST
spam_OUTMITVMA.MIT.EDU>
>
> To:
@spam@PICLISTKILLspam
MITVMA.MIT.EDU
>
> cc: (bcc: Andrew Kunz/TDI_NOTES)
>
> Subject: Re: [PIC]: Sending the last byte in a 2 wire RS485
> transmission
>
> So, what exactly is the problem?
>
> Are you saying you don't want the TXIF interrupt to be set off when you send the
> last byte? You can turn it off for the last byte.
>
> I assume you have a routine that starts the transmission of your packet of
> data. In this routine clear the TXIF bit, and enable the TXIF interrupt. In
> your TXIF interrupt routine you should be able to tell when your packet buffer
> is empty. Immediately before placing the last byte into txreg, disable the TXIF
> interrupt. This will make it so that interrupt occurs ONLY when you have data
> to send, and the txreg is available.
>
> I would avoid workarounds like truncating bytes and such, it makes code reuse
> and maintenance a pain in the neck.
>
> -Adam
>
> Simon Nield wrote:
> >
> > Background:
> > I have a 16f877 running at 20MHz communicating with a PC using 2 wire RS485 at
> 115200 baud.
> > In other words it's half-duplex. The PC sends out a request and the PIC then
> responds with a load of
> > data.
> > The transmission from the PIC is all dealt with via interrupts and the
> hardware USART.
> >
> > Problem:
> > When the last byte is moved from the TXREG into the TSR for shifting out, the
> TXIF interrupt goes
> > off...
> > If I disable the 485 output buffer now then I will truncate the last byte.
> > If I send a dummy byte now and disable when _that_ is moved into the TSR
> then I send an extra byte
> > of garbage... also this does not seem to work reliably
> > If I sit polling (TXSTA, TRMT) until the transmission is done then I waste
> almost 400 instruction
> > cycles.
> >
> > Question:
> > Have any of you run in to this problem before and found an elegant solution ?
> >
> > Thanks,
> > Simon
> >
> > --
> >
http://www.piclist.com hint: PICList Posts must start with ONE topic:
> > [PIC]: PIC only [EE]: engineering [OT]: off topic [AD]: advertisements
>
> --
>
http://www.piclist.com hint: PICList Posts must start with ONE topic:
> [PIC]: PIC only [EE]: engineering [OT]: off topic [AD]: advertisements
>
> --
>
http://www.piclist.com hint: PICList Posts must start with ONE topic:
> [PIC]: PIC only [EE]: engineering [OT]: off topic [AD]: advertisements