Hi,
We are having an issue setting the TLR register of the TL16C754B.
The below algorithm as mentioned in the Programmer's Guide has been tried out.
But when ever the value is read back it doesn't match with the written value. (most of the read back yield 1F)
Read LCR (03), save in temp1
Set LCR (03) to BF
Read EFR (02), save in temp2
Set EFR (02) to 10 + temp2
Set LCR (03) to 00
Read MCR (04), save in temp3
Set MCR (04) to 40 + temp3
Set TLR (07) to VALUE
Set LCR (03) to BF
Set EFR (02) to temp2
Set LCR (03) to temp1
Set MCR (04) to temp3
Code
-------------------
//Read the LCR register
LCRtemp = Read_Uart(REG_LCR);
//Set the LCR register to 0xBF
Write_Uart(REG_LCR, 0xBF);
//Read the LCR register
value8_2 = Read_Uart(REG_LCR); //Should equal 0xbf
if(value8_2 != 0xBF)
{
printf("FIFOTriggerLevels : Read LCR Error\n");
}
//Read the EFR register
EFRtemp = Read_Uart(REG_EFR);
//Set the EFR register to EFRtemp | 0x10 to enable enhanced functions
Write_Uart(REG_EFR, EFRtemp | 0x10);
//Read the EFR register
value8_2 = Read_Uart(REG_EFR);
if(value8_2 != (EFRtemp | 0x10))
{
printf("FIFOTriggerLevels : Read EFR Error\n");
}
//Set the LCR register to 0x00
Write_Uart(REG_LCR, 0x00);
//Read the LCR register
value8_2 = Read_Uart(REG_LCR); //Should equal 0x00
if(value8_2 != 0x00)
{
printf("FIFOTriggerLevels : Read LCR Error\n");
}
//Read the MCR register
MCRtemp = Read_Uart(REG_MCR);
//Set the MCR register to MCRtemp | 0x40 to enable access to TCR and TLR registers
Write_Uart(REG_MCR, MCRtemp | 0x40);
//Read the MCR register
value8_2 = Read_Uart(REG_MCR);
if(value8_2 != (MCRtemp | 0x40))
{
printf("FIFOTriggerLevels : Read MCR Error\n");
}
//Set the trigger level register
value8 = transmit_fifo_trigger_level | (receive_fifo_trigger_level << 4);
Write_Uart(REG_TLR, value8);
//Read the trigger level register
value8_2 = Read_Uart(REG_TLR);
printf("value set = %x, value get = %x\n", value8, value8_2);
if(value8_2 != value8)
{
printf("FIFOTriggerLevels : Read TLR Error\n");
}
//Set LCR register back to 0xBF
Write_Uart(REG_LCR, 0xbf);
//Read the LCR register
value8_2 = Read_Uart(REG_LCR);
if(value8_2 != 0xbf)
{
printf("FIFOTriggerLevels : Read LCR Error\n");
}
//Set EFR register back to original value
Write_Uart(REG_EFR, EFRtemp);
//Read the EFR register
value8_2 = Read_Uart(REG_EFR);
if(value8_2 != EFRtemp)
{
printf("FIFOTriggerLevels : Read EFR Error\n");
}
//Set LCR register back to original value
Write_Uart(REG_LCR, LCRtemp);
//Read the LCR register
value8_2 = Read_Uart(REG_LCR);
if(value8_2 != LCRtemp)
{
printf("FIFOTriggerLevels : Read LCR Error\n");
}
//Set MCR register back to original value
Write_Uart(REG_MCR, MCRtemp);
//Read the MCR register
value8_2 = Read_Uart(REG_MCR);
if((value8_2 & 0xBf) != (MCRtemp & 0xBF)) //Allowing for extended function TLR/TCR enable
{
printf("FIFOTriggerLevels : Read MCR Error\n");
}
Also please be noted that the TCR register can be set successfully by following the Programmer's Guide
Could you please suggest how to write the TLR register?
Thank you for your time.
Regards
Benny