I use UART1 to connect to RS485. For it
I need to enable RS485 transmitter before sending
and again desible it when sending is over.
Below is my code:
void Transmit1(int ch)
{
U32 enabled_interrupts;
// wait for transmission completed
while (!(U1LSR & TEMT));
enabled_interrupts = VICIntEnable; //disable all interrupts
VICIntEnClr = enabled_interrupts;
U1THR = ch;
//while (IO0PIN & Bit(15));
T1EMR = Bit(2); // ExtMatch2 = 1
T1MR2 = T1TC + 10*60000000/115200;
T1EMR |= Bit(8); // ClearOnExtMatch2
VICIntEnable = enabled_interrupts;
}
Problem:
the U1THR = ch; operator does not start sending
immediatelly. There is a random delay in range
approximatelly from 0 to 1 bit duration.
I made different experiments to reset the baudrate
counter or other means but without result. Only
way I found to solve the problem was an extra pin
(P0.15 in my case) usage to detect the real start
of trasmittion, this is done by commented while.
So one needs to use an extra pin and accept, that
interruptions could be desible by up to one bit
duration.
Maybe somebody knows how to force the UART1 start
to transmit the character immediatelly after writing
to U1THR register.
Thanks in advance,
VaruzhanMessage
RS485 and UART1
2006-02-06 by varuzhandanielyan
Attachments
- No local attachments were found for this message.