你的浏览器版本过低,可能导致网站不能正常访问!
为了你能正常使用网站功能,请使用这些浏览器。

stm32 f3 外拓AD5313R 应该如何配置和发数据

[复制链接]
中滑好栗子 提问时间:2017-1-4 11:35 /
这是我写的代码:
SPI3_DAC :static void SPI3_Config(void)
{       
        SPI_InitTypeDef  SPI_InitStructure;
        GPIO_InitTypeDef GPIO_InitStructure;
       
  RCC_APB1PeriphClockCmd(RCC_APB1Periph_SPI3, ENABLE);       
  RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOC, ENABLE);        
        RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOA, ENABLE);
       
  GPIO_PinAFConfig(GPIOC, GPIO_PinSource11, GPIO_AF_6);
  GPIO_PinAFConfig(GPIOC, GPIO_PinSource12, GPIO_AF_6);
       
        GPIO_InitStructure.GPIO_Pin = GPIO_Pin_15;                                        //СDA_SYNC
        GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
        GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
  GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
        GPIO_Init(GPIOA, &GPIO_InitStructure);
       
        GPIO_InitStructure.GPIO_Pin = GPIO_Pin_10;                                        //SPI3_SCK
        GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
        GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
  GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
        GPIO_Init(GPIOC, &GPIO_InitStructure);
       
        /* Configure SPI3 pins:  MISO and MOSI ---------------------------------*/
  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
  GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
  GPIO_InitStructure.GPIO_PuPd  = GPIO_PuPd_DOWN;
  GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;

  GPIO_InitStructure.GPIO_Pin =  GPIO_Pin_11;                                        //SPI3_MISO
  GPIO_Init(GPIOC, &GPIO_InitStructure);
       
        GPIO_InitStructure.GPIO_Pin =  GPIO_Pin_12;                                        //SPI3_MOSI
  GPIO_Init(GPIOC, &GPIO_InitStructure);

  SPI_InitStructure.SPI_Direction = SPI_Direction_2Lines_FullDuplex;
  SPI_InitStructure.SPI_Mode = SPI_Mode_Master;
  SPI_InitStructure.SPI_DataSize = SPI_DataSize_8b;
  SPI_InitStructure.SPI_CPOL = SPI_CPOL_High;
  SPI_InitStructure.SPI_CPHA = SPI_CPHA_2Edge;
  SPI_InitStructure.SPI_NSS = SPI_NSS_Soft;
  SPI_InitStructure.SPI_BaudRatePrescaler = SPI_BaudRatePrescaler_64;
  SPI_InitStructure.SPI_FirstBit = SPI_FirstBit_MSB;
  SPI_InitStructure.SPI_CRCPolynomial = 7;
  SPI_Init(SPI3, &SPI_InitStructure);

        SPI_CalculateCRC(SPI3, ENABLE);
        SPI_Cmd(SPI3, ENABLE);

        SPI_I2S_ITConfig(SPI3, SPI_I2S_IT_TXE, ENABLE);       
        SPI_SendData8(SPI3, 0X00);       
}

利用中断发送数据:
u8 TxBuffer[3] = {0x21,0xff,0x30};

void SPI3_IRQHandler(void)
{
        static uint32_t Tx_Idx = 0;

  GPIO_ResetBits(GPIOA, GPIO_Pin_15);
        GPIO_SetBits(GPIOC, GPIO_Pin_10);
  if (SPI_I2S_GetITStatus(SPI3, SPI_I2S_IT_TXE) == SET)
  {
    SPI_SendData8(SPI3, TxBuffer[Tx_Idx++]);
               
      if (Tx_Idx ==2)
      {
        SPI_I2S_ITConfig(SPI3, SPI_I2S_IT_TXE, DISABLE);
                               
                                Tx_Idx = 0;
                               
                                GPIO_SetBits(GPIOA, GPIO_Pin_15);
                                GPIO_ResetBits(GPIOC, GPIO_Pin_10);
      }
  }                 
}


求助 是为什么DAC_OUT无法输出电压。
收藏 1 评论7 发布时间:2017-1-4 11:35

举报

7个回答
中滑好栗子 回答时间:2017-1-4 11:36:59
各位大神 帮帮忙啦
any012 回答时间:2017-1-4 12:51:49
可以试试非中断方式。
AD的片子,很多都有官方的实例代码。对照着把通讯部分补上去就可以了。

评分

参与人数 1ST金币 +2 收起 理由
zero99 + 2

查看全部评分

lili0000 回答时间:2017-1-4 13:32:47
官方的可以参考下
中滑好栗子 回答时间:2017-1-4 13:44:04
any012 发表于 2017-1-4 12:51
可以试试非中断方式。
AD的片子,很多都有官方的实例代码。对照着把通讯部分补上去就可以了。 ...

我找过AD5313R的基本上都是用户手册 那么 请教官网应该是用什么搜(我也用过datasheets)
中滑好栗子 回答时间:2017-1-4 13:45:09
lili0000 发表于 2017-1-4 13:32
官方的可以参考下

嗯 请教下 应该搜索什么 我搜索过AD5313R 但是都是用户手册 没有显示官网之类的东西
any012 回答时间:2017-1-4 14:17:54
中滑好栗子 发表于 2017-1-4 13:44
我找过AD5313R的基本上都是用户手册 那么 请教官网应该是用什么搜(我也用过datasheets) ...

抱歉,我有点想当然了。
搜了下ADI官网,ADR5313R官网上找不到编程参考。

建议用示波器看下SPI相关引脚波形。
中滑好栗子 回答时间:2017-1-4 14:35:33
any012 发表于 2017-1-4 14:17
抱歉,我有点想当然了。
搜了下ADI官网,ADR5313R官网上找不到编程参考。

嗯  好的 谢谢

所属标签

相似问题

关于
我们是谁
投资者关系
意法半导体可持续发展举措
创新与技术
意法半导体官网
联系我们
联系ST分支机构
寻找销售人员和分销渠道
社区
媒体中心
活动与培训
隐私策略
隐私策略
Cookies管理
行使您的权利
官方最新发布
STM32N6 AI生态系统
STM32MCU,MPU高性能GUI
ST ACEPACK电源模块
意法半导体生物传感器
STM32Cube扩展软件包
关注我们
微信公众号二维码 微信公众号
手机版二维码 手机版