This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

[参考译文] MSP430F6776A:LCD 段显示问题。

Guru**** 2378650 points
请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

https://e2e.ti.com/support/microcontrollers/msp-low-power-microcontrollers-group/msp430/f/msp-low-power-microcontroller-forum/1534832/msp430f6776a-lcd-segment-display-issues

器件型号:MSP430F6776A

工具/软件:

您好:
我不熟悉嵌入式系统、我尝试获得一个 LCD 板、其中 MSP 芯片作为主器件、LCD 作为从器件。
我使用了 Command 寄存器(位于文档中的第 6 页)来打开和关闭所有 LCD 段、但无法点亮特定的 LCD 段。
文档第 9 页显示了设置此项的示例、我的协议分析器上有数据、事务正在进行。
我的事务数据是 ICSET -> ADSET ->我要显示前 2 个段中的哪些位。 它与示例匹配、但不起作用。

什么是我的缺失?
谢谢。

LCD 板文档

工程

#include <msp430.h>
#include <stdio.h>

unsigned char TXData;
unsigned char TXByteCtr;

unsigned long TXDataBuffer[]={0x58,0x00,0xE8}; //These are sent in reverse order
//0x58,0x00,0xC8,0xE8

int bulkTX = 0;
unsigned long TXDataBufferSingle;

void main(void)
{
    WDTCTL = WDTPW | WDTHOLD;                         // Stop WDT

    // Setup P2.5 UCB0SCL, P2.6 UCB0SDA
    P4SEL0 |= BIT4 | BIT5;                             // Set P4.4,P4.5 to UCB1SCL, UCB1SDA

    //Setup LCD_PWR_EN
    P5DIR |= BIT0;
    P5OUT |= BIT0; //Turn on LCD power

    __delay_cycles(6000); //Delay for LCD power to startup, review timing

    // Setup eUSCI_B0
    UCB1CTLW0 |= UCSWRST;                             // Enable SW reset
    UCB1CTLW0 |= UCMST | UCMODE_3 | UCSSEL_2;         // I2C Master, use SMCLK

    UCB1BRW_L = 12;                                   // fSCL = SMCLK/10 = ~95104.5kHz, /11 = 95kHz, /12= 87kHz
    UCB1BRW_H = 0;
    UCB1I2CSA = 0x3E;                                 // Slave Address is 03Eh
    UCB1CTLW0 &= ~UCSWRST;                            // Clear SW reset, resume operation
    UCB1IE |= (UCTXIE0 | UCNACKIE);                   // Enable TX interrupt and NACK interrupt
    TXData = 0x7A;                                    // Holds TX data, sending 0x7A for all pixels ON command to LCD

    bulkTX = 0;
    TXByteCtr = 1;
    TXDataBufferSingle = 0x79;
    while (UCB1CTLW0 & UCTXSTP) ;                 // Ensure stop condition got sent
    UCB1CTLW0 |= UCTR | UCTXSTT;                  // I2C TX, start condition
    __bis_SR_register(LPM0_bits | GIE);           // Enter LPM0 w/ interrupts
    __no_operation();                             // Remain in LPM0 until all data


    while (1)
    {
        bulkTX = 1;
        TXByteCtr = 3;                                // Load TX byte counter

        while (UCB1CTLW0 & UCTXSTP) ;                 // Ensure stop condition got sent
        UCB1CTLW0 |= UCTR | UCTXSTT;                  // I2C TX, start condition
        UCB1TXBUF = TXDataBuffer[2]; // first byte (0xE8)
        __bis_SR_register(LPM0_bits | GIE);           // Enter LPM0 w/ interrupts
        __no_operation();                             // Remain in LPM0 until all data
                                                      // is TX'd

        //TXData++;                                     // Increment data byte
    }
}

//------------------------------------------------------------------------------
// The USCIAB0_ISR is structured such that it can be used to transmit any
// number of bytes by pre-loading TXByteCtr with the byte count.
//------------------------------------------------------------------------------
// USCI_B0 interrupt service routine
#if defined(__TI_COMPILER_VERSION__) || defined(__IAR_SYSTEMS_ICC__)
#pragma vector = USCI_B1_VECTOR
__interrupt void USCI_B1_ISR(void)
#elif defined(__GNUC__)
void __attribute__ ((interrupt(USCI_B1_VECTOR))) USCI_B1_ISR (void)
#else
#error Compiler not supported!
#endif
{
    switch (__even_in_range(UCB1IV, 30))
    {
        case USCI_NONE: break;                        // No interrupts
        case USCI_I2C_UCALIFG: break;                 // ALIFG
        case USCI_I2C_UCNACKIFG:
            UCB1CTL1 |= UCTXSTP;                      // Generate I2C stop condition because communication failed
            break;               // NACKIFG
        case USCI_I2C_UCSTTIFG: break;                // STTIFG
        case USCI_I2C_UCSTPIFG: break;                // STPIFG
        case USCI_I2C_UCRXIFG3: break;                // RXIFG3
        case USCI_I2C_UCTXIFG3: break;                // TXIFG3
        case USCI_I2C_UCRXIFG2: break;                // RXIFG2
        case USCI_I2C_UCTXIFG2: break;                // TXIFG2
        case USCI_I2C_UCRXIFG1: break;                // RXIFG1
        case USCI_I2C_UCTXIFG1: break;                // TXIFG1
        case USCI_I2C_UCRXIFG0: break;                // RXIFG0
        case USCI_I2C_UCTXIFG0:                       // TXIFG0
            if(TXByteCtr && bulkTX == 1){
                UCB1TXBUF = TXDataBuffer[(TXByteCtr-1)];
                TXByteCtr--;
            }
            else if(TXByteCtr && bulkTX == 0){
                UCB1TXBUF = TXDataBufferSingle;
                TXByteCtr--;
            }
            else{
                UCB1IFG &= ~UCTXIFG;                  // Clear USCI_B0 TX int flag                UCB1CTL1 |= UCTXSTP;                  // I2C stop condition
                UCB1CTL1 |= UCTXSTP;                      // Generate I2C stop condition because communication failed
                __delay_cycles(600000); //Delay between sending I2C messages
                __bic_SR_register_on_exit(LPM0_bits); // Exit LPM0
            }

            /*
            //Code below worked well, added above to send multiple bytes
            if (TXByteCtr)                            // Check TX byte counter
            {
                UCB1TXBUF = TXData;                   // Load TX buffer
                TXByteCtr--;                          // Decrement TX byte counter
            }
            else
            {
                UCB1IFG &= ~UCTXIFG;                  // Clear USCI_B0 TX int flag                UCB1CTL1 |= UCTXSTP;                  // I2C stop condition
                UCB1CTL1 |= UCTXSTP;                      // Generate I2C stop condition because communication failed
                __delay_cycles(600000); //Delay between sending I2C messages
                __bic_SR_register_on_exit(LPM0_bits); // Exit LPM0
            }
            */
            break;
        case USCI_I2C_UCBCNTIFG: break;               // CNTIFG
        case USCI_I2C_UCCLTOIFG: break;               // LTOIFG
        case USCI_I2C_UCBIT9IFG: break;               // BIT9IFG
        default: break;
    }
}




  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    0x79 是 APCTL (C=0、AON:AOF=01)、表(第 7 页)显示的值表示 All-off[忽略 DDRAM]。 似乎您想要 0x78 (AON:AOF=00)、这意味着“使用 DDRAM“。

    您是否还需要发送 MODSET (C=0、EN=1)、 即 0x48? 复位后显示 EN=0、但您提到能够在没有此功能的情况下点亮段。 (或者 AON:AOF=10 忽略 EN?)

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    我认为就是这样、我没有提到关于空运货站的措辞。  
    将其设置为 0x78 将其修复。
    我不认为我需要一个 modset 来使它正常工作,但有人建议我尝试它。