I am reading in I2C protocol, which fills up a USB_TX_Buffer. I have that buffer in the watch window and can see the values I want filling it up, but when I to transmit it out on the UART TX pin on the F320 all I get is a steady Voltage high signal. The second bit of the code is the UART init. Anyone have any ideas?
else if (TI0) // A TX is complete, handle TX states, inside UART interrupt { TI0 = 0; // Clear transmit flag UART_TX_NDX = 0; // Reset index init_UART(); SCON0 = 0x00; while (!FLAG_UART_TXDONE) ////switch (NEXT_TX_STATE) { ////case STATE_SEND: if (UART_TX_NDX < SMBus_UART0_RX_NDX) { SBUF0 = USB_TX_Buffer[UART_TX_NDX++]; } if (UART_TX_NDX == SMBus_UART0_RX_NDX) { FLAG_UART_TXDONE = 1; } ////break; ////default: ////break; } } void init_UART(void) { TMOD |= 0x20; // Timer 1 8-bitcounter/timer w auto-reload CKCON = 0x08; // Timer 1 uses the system clock/1 TH1 = 0x30; // Timer 1 Equation17.1 BaudRate for 57600 & 24Mhz ////TL1 = 0x30; // Low bytes of Timer 1 TR1 = 1; // Timer 1 on S0MODE = 0; // 8 bit UART with Variable Baud Rate RI0 = 0; // Recieve Flag (Clear by software) ES0 = 1; // Enable UART interrupts SCON0 |= 0x10; // Enable receive (REN0 is 1) ////PS0 = 1; // Set to high priority }
When I change the TIO part of the UART interrupt to the following code below to just output a steady value there is no probelm. Only when I try to put the USB_TX_Buffer[UART_TX_NDX++] into the SBUF0 it stops working. I put the EIEI1 &= ~0x02 to dissable the USB interrupt thinking maybe the code was going for an adventure there, but didnt help.
else if (TI0) // A TX is complete, handle TX states ----------------------- { TI0 = 0; // Clear transmit flag UART_TX_NDX = 0; // Reset index ////SCON0 = 0x00; ////TR1 = 1; while (!FLAG_UART_TXDONE) ////switch (NEXT_TX_STATE) { EIE1 &= ~0x02; // Disable USB0 interrupt ////case STATE_SEND: if (UART_TX_NDX < SMBus_UART0_RX_NDX) { ////SBUF0 = USB_TX_Buffer[UART_TX_NDX++]; SBUF0 = 0xFF; } ////if (UART_TX_NDX == SMBus_UART0_RX_NDX) ////{ //// FLAG_UART_TXDONE = 1; //// } ////break; ////default: ////break; }