<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>LPC MicrocontrollersのトピックRe: SC16IS752 Trigger Levels</title>
    <link>https://community.nxp.com/t5/LPC-Microcontrollers/SC16IS752-Trigger-Levels/m-p/522364#M5000</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by manoffline on Wed Oct 08 11:18:56 MST 2014&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;I found the problem.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I have a function to flush all RX/TX data, and it was corrupting the FCR register value. It was solved after I fixed this.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 15 Jun 2016 16:38:14 GMT</pubDate>
    <dc:creator>lpcware</dc:creator>
    <dc:date>2016-06-15T16:38:14Z</dc:date>
    <item>
      <title>SC16IS752 Trigger Levels</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/SC16IS752-Trigger-Levels/m-p/522363#M4999</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by manoffline on Wed Oct 08 10:51:50 MST 2014&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;Hello Folks,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I've been using this SPI-UART bridge for years and faced and resolver issues with the driver during all this time. But now I'm facing a problem I can't solve.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The RX trigger level is always triggering at 60 bytes, not at the configured level, causing data loss.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This is the function to open external UARTs (from bridge):&lt;/SPAN&gt;&lt;BR /&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD bgcolor="#cacaca"&gt; &lt;PRE&gt;
static void sc16is752_uarts_open(uid_type uid, uint32_t baudrate, uint32_t format)
{
&amp;nbsp; uint8_t DLL_value;
&amp;nbsp; vuart_map_t *vuart = get_uart(uid);
&amp;nbsp; uint8_t channel = uid % 2;

&amp;nbsp; NVIC_DisableIRQ(EINT1_IRQn);
#if BSP_EINT2_EN == 1
&amp;nbsp; NVIC_DisableIRQ(EINT2_IRQn);
#endif

&amp;nbsp; //Most common baud rates values
&amp;nbsp; //divisor = 1.8432MHz / (baud rate * 16 * prescaler), prescaler = 1
&amp;nbsp; spi_wr_sc16is752(SC16IS752_LCR, 0x80, channel, vuart); /* 0x80 to program baud-rate */
&amp;nbsp; switch (baudrate)
&amp;nbsp; {
&amp;nbsp; case 1200: DLL_value = 0x60; break;
&amp;nbsp; case 1800: DLL_value = 0x40; break;
&amp;nbsp; case 2400: DLL_value = 0x30; break;
&amp;nbsp; case 3600: DLL_value = 0x20; break;
&amp;nbsp; case 4800: DLL_value = 0x18; break;
&amp;nbsp; case 7200: DLL_value = 0x10; break;
&amp;nbsp; case 9600: DLL_value = 0x0C; break;
&amp;nbsp; case 19200: DLL_value = 0x06; break;
&amp;nbsp; case 38400: DLL_value = 0x03; break;
&amp;nbsp; case 115200: DLL_value = 0x01; break;
&amp;nbsp; default: /* default baud rate is 9600 */
&amp;nbsp;&amp;nbsp;&amp;nbsp; DLL_value = 0x0C;
&amp;nbsp; }

&amp;nbsp; spi_wr_sc16is752(SC16IS752_DLL, DLL_value, channel, vuart);
&amp;nbsp; spi_wr_sc16is752(SC16IS752_DLH, 0x0, channel, vuart);

&amp;nbsp; spi_wr_sc16is752(SC16IS752_LCR, 0xBF, channel, vuart); /* 0xBF to access EFR register */
&amp;nbsp; spi_wr_sc16is752(SC16IS752_EFR, 0x10, channel, vuart); /* Enable enhanced registers */

//&amp;nbsp; spi_wr_sc16is752(SC16IS752_MCR, 0x04, channel, vuart); /* Enable TLR register writing */
//&amp;nbsp; spi_wr_sc16is752(SC16IS752_TLR, 0x20, channel, vuart); /* setting it to 0 uses the FCR levels */
//&amp;nbsp; spi_wr_sc16is752(SC16IS752_MCR, 0x00, channel, vuart); /* Disable TLR register writing */

&amp;nbsp; /* set UART data communication format */
&amp;nbsp; spi_wr_sc16is752(SC16IS752_LCR, format, channel, vuart);

&amp;nbsp; spi_wr_sc16is752(SC16IS752_EFCR, 0x30, channel, vuart); /* inverted, RS485 RTS dir control */
&amp;nbsp; spi_wr_sc16is752(SC16IS752_IER, SC16IS752_IER_RHRI|SC16IS752_IER_RLSI, channel, vuart); /* enable reception interrupt */

&amp;nbsp; /* Clears the contents of the receive and transmit FIFO, set trigger levels */
&amp;nbsp; spi_wr_sc16is752(SC16IS752_FCR, SC16IS752_FCR_FIFO_FLSH, channel, vuart);
&amp;nbsp; spi_wr_sc16is752(SC16IS752_FCR, SC16IS752_FCR_FIFO_CONF, channel, vuart);
&amp;nbsp; /* Enable FIFO mode */
//&amp;nbsp; spi_wr_sc16is752(SC16IS752_FCR, SC16IS752_FCR_FIFO_EN, channel, vuart);

&amp;nbsp; NVIC_EnableIRQ(EINT1_IRQn);
#if BSP_EINT2_EN == 1
&amp;nbsp; NVIC_EnableIRQ(EINT2_IRQn);
#endif
}
&lt;/PRE&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;When the interrupt source is RHR (trigger level reached), the RXLVL is 60, which means the IRQ was triggered when 60 bytes were at the RX FIFO. If I place a breakpoint and right read the RXLVL again, the value increases to 64 (FIFO full).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This is the IRQ handler:&lt;/SPAN&gt;&lt;BR /&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD bgcolor="#cacaca"&gt; &lt;PRE&gt;
void sc16is752_irq_handler(uid_type uid)
{
&amp;nbsp; uint8_t IIR_value, LSR_value, IER_value, RXLVL_value, count, read_byte, channel = uid%2;

#if VUART_EN == 1
&amp;nbsp; vuart_map_t *vuart = get_uart(uid);
#endif

&amp;nbsp; LSR_value = spi_rd_sc16is752(SC16IS752_LSR, channel, vuart);
&amp;nbsp; uart_lines[uid].line_status |= (LSR_value &amp;amp; LSR_OE);

&amp;nbsp; if (LSR_value &amp;amp; SC16IS752_LSR_OE) {
&amp;nbsp;&amp;nbsp;&amp;nbsp; log_string(LOG_ERROR, "OVERRUN EXTERNAL UART %u.", uid);
&amp;nbsp; }

&amp;nbsp; switch ((IIR_value = spi_rd_sc16is752(SC16IS752_IIR, channel, vuart)) &amp;amp; 0x0F)
&amp;nbsp; {
&amp;nbsp; case SC16IS752_IIR_RLS: // receiver line status (LSR)
&amp;nbsp; case SC16IS752_IIR_RTI: // receiver time-out interrupt
&amp;nbsp; case SC16IS752_IIR_RHR: // receive hold register (RHR) interrupt

&amp;nbsp;&amp;nbsp;&amp;nbsp; RXLVL_value = spi_rd_sc16is752(SC16IS752_RXLVL, channel, vuart);

&amp;nbsp;&amp;nbsp;&amp;nbsp; if ((IIR_value &amp;amp; 0x0F) == SC16IS752_IIR_RHR) {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; __asm("NOP\n") ;
&amp;nbsp;&amp;nbsp;&amp;nbsp; }

&amp;nbsp;&amp;nbsp;&amp;nbsp; RXLVL_value = spi_rd_sc16is752(SC16IS752_RXLVL, channel, vuart);

&amp;nbsp;&amp;nbsp;&amp;nbsp; /* this will only happen when the chip loose the interrupt sync, dummy read for re-sync */
&amp;nbsp;&amp;nbsp;&amp;nbsp; if (!(LSR_value &amp;amp; SC16IS752_LSR_RHR)) {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; spi_rd_sc16is752(SC16IS752_RHR, channel, vuart);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; log_string(LOG_WARN, "EXTERNAL UART %u OUT OF SYNC, RE-SYNC.", uid);
&amp;nbsp;&amp;nbsp;&amp;nbsp; }

&amp;nbsp;&amp;nbsp;&amp;nbsp; /* Repeat until receiver FIFO is empty */
&amp;nbsp;&amp;nbsp;&amp;nbsp; count = 0;
&amp;nbsp;&amp;nbsp;&amp;nbsp; while (LSR_value &amp;amp; SC16IS752_LSR_RHR) {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* Get errors */
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; uart_lines[uid].line_status |= (LSR_value &amp;amp; (LSR_BI|LSR_FE|LSR_PE));
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* Get the byte */

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; read_byte = spi_rd_sc16is752(SC16IS752_RHR, channel, vuart);

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* if the queue is full, don't increment the in index */
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (((uart_lines[uid].in + 1) &amp;amp; INPUT_QUEUE_MASK) == uart_lines[uid].out) {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; uart_lines[uid].line_status |= U_ST_CQOE; /* Overrun Error */
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; log_string(LOG_ERROR, "OVERRUN UART %u.", uid);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; } else {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; uart_lines[uid].ibuf[uart_lines[uid].in] = read_byte;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; uart_lines[uid].in = (uart_lines[uid].in + 1) &amp;amp; INPUT_QUEUE_MASK;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; count++;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; LSR_value = spi_rd_sc16is752(SC16IS752_LSR, channel, vuart);
//&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; isr_PostSem(uart_lines[uid].semRx, 1);
&amp;nbsp;&amp;nbsp;&amp;nbsp; }
&amp;nbsp;&amp;nbsp;&amp;nbsp; /* Increment the semaphore. This tells the task that the incoming bytes have been read. */
&amp;nbsp;&amp;nbsp;&amp;nbsp; isr_PostSem(uart_lines[uid].semRx, count);
&amp;nbsp;&amp;nbsp;&amp;nbsp; break;

&amp;nbsp; case SC16IS752_IIR_THR: // transmit hold register (THR) interrupt
&amp;nbsp;&amp;nbsp;&amp;nbsp; read_byte = spi_rd_sc16is752(SC16IS752_TXLVL, channel, vuart);
&amp;nbsp;&amp;nbsp;&amp;nbsp; fill_output_fifo(uid, read_byte);

&amp;nbsp;&amp;nbsp;&amp;nbsp; if (uart_lines[uid].olen == 0) /* All bytes transmitted? */
&amp;nbsp;&amp;nbsp;&amp;nbsp; {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //disable transmission interrupt
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; IER_value = spi_rd_sc16is752(SC16IS752_IER, channel, vuart);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; IER_value &amp;amp;= ~SC16IS752_IER_THRI;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; spi_wr_sc16is752(SC16IS752_IER, IER_value, uid%2, vuart);

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* Release the semaphore.
This tells the task that its output buffer has beencopied to the uart fifo. */
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; isr_PostSem(uart_lines[uid].semTx, 1);
&amp;nbsp;&amp;nbsp;&amp;nbsp; }

&amp;nbsp;&amp;nbsp;&amp;nbsp; break;

&amp;nbsp; default:
&amp;nbsp;&amp;nbsp;&amp;nbsp; break;
&amp;nbsp; }
}
&lt;/PRE&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks in advance,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Mariano.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 16:38:13 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/SC16IS752-Trigger-Levels/m-p/522363#M4999</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T16:38:13Z</dc:date>
    </item>
    <item>
      <title>Re: SC16IS752 Trigger Levels</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/SC16IS752-Trigger-Levels/m-p/522364#M5000</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by manoffline on Wed Oct 08 11:18:56 MST 2014&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;I found the problem.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I have a function to flush all RX/TX data, and it was corrupting the FCR register value. It was solved after I fixed this.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 16:38:14 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/SC16IS752-Trigger-Levels/m-p/522364#M5000</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T16:38:14Z</dc:date>
    </item>
    <item>
      <title>Re: SC16IS752 Trigger Levels</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/SC16IS752-Trigger-Levels/m-p/522365#M5001</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Could You please explain me why there is NOP in irq receive handler and RXLVL register is readed twice? When I read RXLVL register and there is 2 more bytes received (ie. 10) then trigger level (ie. 8),&amp;nbsp;RXLVL returns trigger level bytes qty (ie 8 insteed of 10). There is no problem if there is more bytes in FIFO. Could it be because of reading RXLVL while receiving data?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 11 Jan 2017 08:08:31 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/SC16IS752-Trigger-Levels/m-p/522365#M5001</guid>
      <dc:creator>svavo</dc:creator>
      <dc:date>2017-01-11T08:08:31Z</dc:date>
    </item>
  </channel>
</rss>

