Announcement

Collapse
No announcement yet.

GEN4-ULCD-43DT & custom PCB- (display is not detected) bit string is always zero

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • ESPsupport
    replied
    The idle state of a uart is high, plus the RX on the gen 4 would be what is generated by your LPC1519, so, based on what you have said so far everything seems OK, until you send something from the LPC.


    Leave a comment:


  • GEN4-ULCD-43DT & custom PCB- (display is not detected) bit string is always zero

    Hi,
    I am trying to use a custom PCB (LPC1519 microcontroller) as a host controller for the GEN4-ULCD-43DT via UART.
    I have check the TX and RX signals using an oscilloscope and they are a constant HIGH. However, both the TX and RX bit string is always 0.
    Are there any suggestions why this would be happening?




    Code:
    [B]#include[/B] <toucan.h>
    [B]#include[/B] <tc_error.h>
    [B]#include[/B] <tc_nvic.h>
    [B]#include[/B] <tc_can.h>
    [B]#include[/B] <tc_gpio.h>
    [B]#include[/B] <tc_timer.h>
    [B]#include[/B] <tc_uart.h>
    [B]#include[/B] <tc_adc.h>
    [B]#include[/B] <tc_eeprom.h>
    [B]#include[/B] <tc_message.h>
    [B]#include[/B] <tc_ws22_driver.h>
    [B]#include[/B] <node_ids.h>
    [B]#include[/B] <uart_receiver.h>
    [B]#include[/B] <tc_spi.h>
    
    
    [B]#include[/B] <visi_genie.h>
    [B]#include[/B] <visi_genie_file_access.h>
    
    
    [B]const[/B] [B]uint32_t[/B] OscRateIn = 12000000;
    [B]const[/B] [B]uint32_t[/B] RTCOscRateIn = 32768;
    
    
    [B]#include[/B] "node_config.h"
    [B]#include[/B] "tc_ws22_driver.h"
    
    
    [B]#define[/B] [B]DRIVE_DEBUG[/B] 1
    [B]#define[/B] [B]DISPLAY_CON_CHANNEL[/B] TC_UART1
    
    
    [B]#define[/B] [B]RESET_PORT[/B] 1
    [B]#define[/B] [B]RESET_PIN[/B] 7
    
    [B]void[/B] [B]myGenieHandler[/B]([B]void[/B]);
    
    
    
    [B]int[/B] [B]main[/B]([B]void[/B]) {
    
    // Read clock settings and update SystemCoreClock variable
    [B]SystemCoreClockUpdate[/B]();
    
      // Initialise toucan
      [B]tc_init[/B](DRIVE_NODE);
      [B]tc_can_init[/B]([I]CP_BAUD_500K[/I]);
    
    
      // Setup status LED pins
      [B]tc_gpio_setPinDir[/B](STATUS_LED_PORT, STATUS_LED_PIN, [I]TC_GPIO_DIR_OUTPUT[/I]);
      [B]tc_gpio_setPinValue[/B](STATUS_LED_PORT, STATUS_LED_PIN, 1);
    
    
      // Setup debug on USB/UART
      // Note: debug uses TC_UART0 (do not use UART0 elsewhere)
      // Note: baud set to 9600 default, increase if required (up to 115200)
      [B]tc_debug_uart_init[/B](9600, UART0_TX_PORT, UART0_TX_PIN, UART0_RX_PORT, UART0_RX_PIN);
    
    
      // Display communication set up- USINT UART
      [B]tc_uart_tx_pinassign[/B](DISPLAY_CON_CHANNEL, 2, 12);
      [B]tc_uart_rx_pinassign[/B](DISPLAY_CON_CHANNEL, 1, 6);
      [B]tc_uart_init[/B](DISPLAY_CON_CHANNEL, 115200, [I]TC_UART_CFG_DATALEN_8[/I], [I]TC_UART_CFG_PARITY_NONE[/I], [I]TC_UART_CFG_STOPLEN_1[/I]);
      [B]tc_uart_init_buffer[/B](DISPLAY_CON_CHANNEL, 256, 256);
    
    
    [B]tc_debug_uart_printf[/B]("Setup 3\n");
    
    
    [B]genieAttachEventHandler[/B]([B]myGenieHandler[/B]);
    [B]genieAttachDebugger[/B]([B]tc_debug_uart_printf[/B]);
    
      [B]genieBegin[/B]();
    
    
    
    
      // Setting up reset
    
      [B]tc_gpio_setPinDir[/B](RESET_PORT, RESET_PIN, [I]TC_GPIO_DIR_OUTPUT[/I]);
    [B] tc_gpio_setPinValue[/B](RESET_PORT, RESET_PIN, 0);
      [B]tc_timer_delay_ms[/B](500);
      [B]tc_gpio_setPinValue[/B](RESET_PORT, RESET_PIN, 1);
      [B]tc_timer_delay_ms[/B](3000);
    
    [B]genieDoEvents[/B]();
      
    [B]genieWriteContrast[/B](15);
    
    [B]genieWriteObject[/B]([I]GENIE_OBJ_LED_DIGITS[/I], 1, 3);
    
      [B]_U08[/B] data = 0xFF;
    
    
    
    
    // Main loop
    
    [B]while[/B](1) {
    
    
    [B]int[/B] result_of_sending = [B]tc_uart_sendBytesBuffered[/B](DISPLAY_CON_CHANNEL, &data, 1);
    
    [B]tc_debug_uart_printf[/B]("Result of sending: %d\n", result_of_sending);
    
    
    
    [B]uint16_t[/B] rx_bytes_used = [B]tc_uart_getRxBuffBytesUsed[/B](DISPLAY_CON_CHANNEL);
    [B]uint16_t[/B] tx_bytes_used = [B]tc_uart_getTxBuffBytesUsed[/B](DISPLAY_CON_CHANNEL);
    [B]uint16_t[/B] rx_bytes_free = [B]tc_uart_getRxBuffBytesFree[/B](DISPLAY_CON_CHANNEL);
    [B]uint16_t[/B] tx_bytes_free = [B]tc_uart_getTxBuffBytesFree[/B](DISPLAY_CON_CHANNEL);
    
    // THESE ARE ALWAYS ZERO
    [B]tc_debug_uart_printf[/B]("RX bytes used: %d, free: %d - in genieGetByteCount()\n", rx_bytes_used, rx_bytes_free);
    [B]tc_debug_uart_printf[/B]("TX bytes used: %d, free: %d - in genieGetByteCount()\n", tx_bytes_used, tx_bytes_free);
    
    
    [B]tc_debug_uart_printf[/B]("FINISH MAIN WHILE LOOP\n");
    
    
    [B]tc_timer_delay_ms[/B](1000);
    }
    
    
    
    
    [B]return[/B] 0;
    }
    
    
    
    
    [B]extern[/B] [B]unsigned[/B] [B]long[/B] [B]millis[/B]([B]void[/B]) {
    
    [B]return[/B] ([B]unsigned[/B] [B]long[/B])[B]tc_timer_get[/B]();
    
    }
    
    
    
    
    [B]extern[/B] [B]uint16_t[/B] [B]genieGetByteCount[/B]([B]void[/B]) {
    
    [B]tc_debug_uart_printf[/B]("INSIDE GENIE GET BYTE COUNT\n");
    
    
    
    [B]uint16_t[/B] rx_bytes_used = [B]tc_uart_getRxBuffBytesUsed[/B](DISPLAY_CON_CHANNEL);
    [B]uint16_t[/B] tx_bytes_used = [B]tc_uart_getTxBuffBytesUsed[/B](DISPLAY_CON_CHANNEL);
    [B]uint16_t[/B] rx_bytes_free = [B]tc_uart_getRxBuffBytesFree[/B](DISPLAY_CON_CHANNEL);
    [B]uint16_t[/B] tx_bytes_free = [B]tc_uart_getTxBuffBytesFree[/B](DISPLAY_CON_CHANNEL);
    
    // THESE ARE ALWAYS ZERO
    [B]tc_debug_uart_printf[/B]("RX bytes used: %d, free: %d - in genieGetByteCount()\n", rx_bytes_used, rx_bytes_free);
    [B]tc_debug_uart_printf[/B]("TX bytes used: %d, free: %d - in genieGetByteCount()\n", tx_bytes_used, tx_bytes_free);
    
    
    [B]tc_debug_uart_printf[/B]("FINISH GENIE GET BYTE COUNT\n");
    
    
    
    
    [B]return[/B] rx_bytes_free;
    }
    
    
    
    
    [B]_U08[/B] peeked;
    
    [B]_U08[/B] dirty = 0;
    
    
    
    
    [B]extern[/B] [B]uint8_t[/B] [B]genieGetByte[/B]([B]void[/B]) {
    
    [B]if[/B] (dirty) {
    
    dirty = 0;
    
    [B]return[/B] peeked;
    
    }
    
    
    
    
    [B]_U08[/B] data;
    
    
    // tc_uart_readBytesBuffered function removes byte from bit string
    
    [B]tc_uart_readBytesBuffered[/B](DISPLAY_CON_CHANNEL, &data, 1);
    
    [B]return[/B] ([B]uint8_t[/B])data;
    
    }
    
    
    [B]extern[/B] [B]uint8_t[/B] [B]geniePeekByte[/B]([B]void[/B]) {
    
    [B]_U08[/B] data;
    
    [B]tc_uart_readBytesBuffered[/B](DISPLAY_CON_CHANNEL, &data, 1);
    
    [B]tc_debug_uart_printf[/B]("RingBuff->data: %d\n", data);
    
    dirty = 1;
    peeked = data;
    
    
    [B]return[/B] data;
    
    }
    
    
    [B]extern[/B] [B]void[/B] [B]geniePutByte[/B]([B]uint8_t[/B] c) {
    
    [B]uint8_t[/B] c1 = c;
    
    [B]tc_uart_sendBytesBlocking[/B](DISPLAY_CON_CHANNEL, &c1, 1);
    
    }
    
    
    
    [B]void[/B] [B]myGenieHandler[/B]([B]void[/B]) {
    
    [B]genieFrame[/B] Event;
    
    [B]genieDequeueEvent[/B](&Event);
    
    
    [B]if[/B] (Event.reportObject.object == GENIE_READY) {
    
    [B]tc_debug_uart_printf[/B]("Inside event handler, genie_ready\n");
    
    }
    
    
    }
    Last edited by Sunswift Racing; 21 March 2021, 03:12 PM.
Working...
X