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.

[参考译文] MSP430FR5969:SPI

Guru**** 2538310 points


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

https://e2e.ti.com/support/microcontrollers/msp-low-power-microcontrollers-group/msp430/f/msp-low-power-microcontroller-forum/1030968/msp430fr5969-spi

器件型号:MSP430FR5969

    UCB0CTLW0 |= UCSWRST;

    UCB0CTLW0 |= UCSSEL_2;
    UCB0BRW = 10;
    UCB0CTLW0 |= UCSYNC;
    UCB0CTLW0 |= UCMST;


    P1SEL1 |= BIT6 + BIT7;
    P1SEL0 |= ~BIT6 + ~BIT7;
    P2SEL1 |= BIT2;
    P2SEL0 &= BIT2;
    PM5CTL0 &= LOCKLPM5;
    UCB0IFG &= ~UCTXIFG;
    UCB0CTLW0 &= ~UCSWRST;
    UCB0IE |= UCTXIE;

    P1SEL1 |= BIT6 + BIT7;

    SLAVE_CS_DIR |= SLAVE_CS_PIN;
    SLAVE_CS_OUT |= SLAVE_CS_PIN;

您好、我尝试在 UCB0上使用 SPI、(橡皮擦/ 3引脚/ SYNC)  在该初始化中是否有错误? MSP 中的即时消息新功能

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

    > P1SEL0 |=~BIT6 +~BIT7;

    这不会将这些位设置为0。 尝试:

    > P1SEL0 &=~(BIT6 + BIT7);

    ----

    >P2SEL0 &= BIT2;

    类似地。 尝试:

    > P2SEL0 &=~BIT2;

    ----

    您已设置(左) UCCKPH=0。 该位的定义与 CPHA 相反、因此如果您的器件期望 CPHA = 0 (这是非常常见的情况)、您应该这样做

    >   UCB0CTLW0 |= UCCKPH;  // CPHA = 0

    ----

    您尚未显示程序的其余部分、但我注意到您正在使用 TXIE/TXIFG 位。  

    1) 1)您已清除 TXIFG、因此您不会获得初始中断来触发第一个字节。 这意味着您必须将第一个字节写入 TXBUF、而无需查看。

    2) 2)通常、对于快速 SPI (我认为 BRW=10计数)、我建议不要使用中断、因为记账和 ISR 开销会占用您节省的任何资源。

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

    好的、thx。 我将尝试不使用中断、并告诉您有关结果的信息

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

    对于短期交易,我从此处讨论的 spix()函数中获得了大量的里程:

    https://e2e.ti.com/support/microcontrollers/msp-low-power-microcontrollers-group/msp430/f/msp-low-power-microcontroller-forum/758000/msp430fr5729-problems-with-implementing-mcp23s08-8-bit-port-expander-on-msp430fr5729/2800722#2800722

    如果您的器件可以使用该函数、则还有 SET_reg 函数。

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

    Thx、我使用您的函数、但没有帮助、可能是其他问题。 IM 初始化 MAX41460、然后我尝试端口 Devkit 生产者代码。

    void initMAX(){
    
        set_reg(0x0A, 0x03);
        set_reg(0x00, 0x95);
        set_reg(0x06, 0x90);
        maxSetFreq(433920000);
        set_reg(0x0A, 0x00);
    
    }
    
    
    void maxSoftReset(){
    
        set_reg(0x17, 0x01);
        __delay_cycles(100);
        set_reg(0x17, 0x00);
        __delay_cycles(1000);
    
    }
    
    void maxSetFreq(uint32_t freq){
    
        float temp_freq;
        uint32_t fin_freq;
    
    
        temp_freq = (float)freq / 1000000;
        temp_freq *= 65536.0;
        temp_freq /= 16;
        fin_freq = (uint32_t)temp_freq;
    
        uint8_t temp = fin_freq >> 16;
        set_reg(0x0B, temp);
        temp = fin_freq >> 8;
        set_reg(0x0c, temp);
        temp = fin_freq;
        set_reg(0x0d, temp);
    
    }
    void set_reg(uint8_t reg, uint8_t value)
    {
        SLAVE_CS_OUT &= ~(SLAVE_CS_PIN);
        reg &= 0x7e;
        spix(reg);        // Register to set
        spix(value);      // Value to set it to
        SLAVE_CS_OUT |= (SLAVE_CS_PIN);
        return;
    }


    生产者代码、ctx 为 SPI 句柄
    void ismtx_soft_reset ( ismtx_t *ctx )
    {
        ismtx_generic_write( ctx, ISMTX_REG_CFG8, 0x01 );
        Delay_100ms(  );
        ismtx_generic_write( ctx, ISMTX_REG_CFG8, 0x00 );
        Delay_1sec(  );
    }
    
    err_t ismtx_default_cfg ( ismtx_t *ctx )
    {
        ismtx_generic_write( ctx, ISMTX_REG_CFG6, 0x03 );
        if ( ISM_TX_MODULATION_FSK == ctx->modulation )
        {
            ismtx_generic_write( ctx, ISMTX_REG_CFG1, 0x95 );
            ismtx_generic_write( ctx, ISMTX_REG_PA1, 0x90 );
            ismtx_set_frequency( ctx, 433920000 );
            ismtx_set_cfg( ctx, ISMTX_CFG_FSK_SHAPE, ISMTX_FSK_SHAPE_ENABLED );
            ismtx_adjust_frequency_deviation( ctx, 40000 );
        }   
        else if ( ISM_TX_MODULATION_ASK == ctx->modulation )
        {
            ismtx_generic_write( ctx, ISMTX_REG_CFG1, 0x90 );
            ismtx_generic_write( ctx, ISMTX_REG_PA1, 0x87 );
            ismtx_set_frequency( ctx, 433920000 );
        }
        else
        {
            return ISMTX_ERROR;
        }
        
        ismtx_generic_write( ctx, ISMTX_REG_CFG6, 0x00 );
        
        return ISMTX_OK;
    }
    
    err_t ismtx_set_frequency ( ismtx_t *ctx, uint32_t freq )
    {
        float temp_freq;
        uint32_t fin_freq;
    
        if ( ( freq > MAX_FREQ ) || ( freq < MIN_FREQ ) )
        {
            return ISMTX_PARAMETER_ERROR;
        }
    
        temp_freq = ( float )freq / MEGA;
        temp_freq *= CONST_MOD_FREQ;
        temp_freq /= CRYSTAL_FREQ;
        fin_freq = ( uint32_t )temp_freq;
    
        ismtx_generic_write( ctx, ISMTX_REG_PLL3, ( fin_freq >> 16 ) );
        ismtx_generic_write( ctx, ISMTX_REG_PLL4, ( fin_freq >> 8 ) );
        ismtx_generic_write( ctx, ISMTX_REG_PLL5, fin_freq );
    
        return ISMTX_OK;
    }
    err_t ismtx_generic_write ( ismtx_t *ctx, uint8_t reg, uint8_t data_in )
    {
        uint8_t tx_buf[ 257 ];
        uint8_t cnt;
    
        tx_buf[ 0 ] = reg & 0x7F;
        tx_buf[ 1 ] = data_in;
    
        spi_master_select_device( ctx->chip_select );
        err_t error_flag = spi_master_write( &ctx->spi, tx_buf, 2 );
        spi_master_deselect_device( ctx->chip_select );
    
        return error_flag;
    }

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

    您的代码有什么作用? 您如何判断它不起作用?

    您是否使用 spix()来实现 spi_master_write(),或者您的第一个代码是否与第二个代码混合?  

    [编辑:您是否设置了 UCCKPH=1? MAX41460数据表图3显示您需要它。]

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

    spix 用于 SET_reg、对于原始数据发送、只需检查 osciloskop 处的 SPI 引脚即可、看起来正常。
    带有  MAX41460的评估套件具有数据指示灯、因此我认为它应该显示任何内容。



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

    您可以尝试读回您设置的寄存器。 我想您必须设置 CFG6:FOURWIRE=1才能使 SDO 正常工作。