I am using a MAX14830 SPI-UART bridge. I am trying to initialize the chip and get it to transmit a few bytes out of one of its UART. I can write to the UART's THR register, which gets added to the TxFIFO of the UART, but the TxFIFO Level keeps increasing. My issue is exactly the same as the one mentioned in this thread. I have checked the ClkDisabl bit as OP mentioned in his answer and the bit is not set.
My initialization procedure for the chip:
- Reset chip by setting RST bit in MODE2 register and then clearing it
- Set the baud rate to 115200 by setting clock divider to 2 (DIVLSB = 2, DIVMSB = 0)
- Set line control register LCR to 3 (8 data bits + 1 stop bit)
- Set TrnscvCtrl bit in MODE1 register
- Clear FIFOs by setting FIFORst bit in the MODE2 register and then clearing it
After this initialization procedure, I write 3 bytes ('A', 'B', and 'C') to the THR registers, when I check the TxFIFOLvl register I see a 3. Every subsequent write just adds to the FIFO and nothing ever goes out the FIFO and I see nothing on the TX line with an oscilloscope. The TxFIFOLvl register returns to 0 only after I clear the FIFOs again or reset the chip.
Any advice on how I can go about debugging the issue or what areas I should look at? Any help would be appreciated! Here's the datasheet for the MAX14830.
EDIT: I tried outputting the UART clock on one of the GPIO pins on the MAX14830 using the ClkToGPIO bit in the TxSynch register, the clock is always high and doesn't seem to be ticking at all. Here's a picture of the voltage across my crystal oscillator. Crystal part number E1SFA12-3.6864M TR. Looks like the peak to peak voltage is about 100mV and the time period is 1us. Does this mean my crystal isn't functioning correctly?
EDIT: Adding my code and logs.
#define IRQ_EN 0x01
#define ISR_REG 0x02
#define MODE1 0x09
#define MODE2 0x0A
#define FLOW_LVL 0x0F
#define LCR_REG 0x0B
#define FIFO_TRIG 0x10
#define TX_FIFO_LVL 0x11
#define RX_FIFO_LVL 0x12
#define FLOW_CTL 0x13
#define BRG_CFG 0x1B
#define DIV_LSB 0x1C
#define DIV_MSB 0x1D
#define CLK_SRC 0x1E
void action() {
SPI_setup();
Particle.publish("Selecting UART1", "Success");
Log.info("Selecting UART1");
delay(1000);
SelectUART(UART1);
Particle.publish("Resetting UART1", "Success");
Log.info("Resetting UART1");
delay(1000);
SPI_writeRegister(MODE2, 1);
delay(500);
SPI_writeRegister(MODE2, 0);
Particle.publish("Setting UART1 baud rate to 115200", "Success"); //clock 3.6864MHz
Log.info("Setting UART1 baud rate to 115200");
delay(1000);
SPI_writeRegister(DIV_MSB, 0);
SPI_writeRegister(DIV_LSB, 2);
//Set 8 bits data + 1 stop bit
SPI_writeRegister(LCR_REG, 3);
//set MODE1 TrnscvCtrl bit
SPI_writeRegister(MODE1, 16);
Particle.publish("Resetting FIFOs UART1", "Success");
Log.info("Resetting FIFOs UART1");
delay(1000);
SPI_writeRegister(MODE2, 2);
delay(500);
SPI_writeRegister(MODE2, 0);
//Clear ISR register by reading from it
SPI_readRegister(ISR_REG);
Particle.publish("Writing to UART1", "Success");
Log.info("Writing to UART1");
delay(1000);
Particle.publish("UART1 TX_FIFO_LVL before write = ", String::format("%d", SPI_readRegister(TX_FIFO_LVL)));
delay(1000);
SPI_writeData(65);
SPI_writeData(66);
SPI_writeData(67);
delay(1000);
Particle.publish("UART1 TX_FIFO_LVL 1s after write = ", String::format("%d", SPI_readRegister(TX_FIFO_LVL)));
delay(1000);
Particle.publish("Selecting UART0", "Success");
Log.info("Selecting UART0");
delay(1000);
SelectUART(UART0);
Particle.publish("UART0 TX_FIFO_LVL after write = ", String::format("%d", SPI_readRegister(TX_FIFO_LVL)));
delay(1000);
}