请教AD5293数字电位器使用

[复制链接]
2042|5
 楼主| chest20090909 发表于 2018-10-20 21:48 | 显示全部楼层 |阅读模式
本帖最后由 chest20090909 于 2018-10-25 08:46 编辑

ddddd
tyw 发表于 2018-10-21 08:37 | 显示全部楼层
本帖最后由 tyw 于 2018-10-21 08:47 编辑





本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?注册

×
877049204 发表于 2018-10-21 12:27 | 显示全部楼层
数字电位器不能用万用表测阻值
Prry 发表于 2018-10-21 21:15 | 显示全部楼层
  1. //spi bus device
  2. static struct spi_dev_device        ad5290_spi_dev[3];
  3. extern struct spi_bus_device        spi_bus1;
  4. static void ad5290_spi_cs0(unsigned char state)
  5. {
  6.         if (state)
  7.                 GPIO_SetBits(GPIOC, GPIO_Pin_7);
  8.     else
  9.                 GPIO_ResetBits(GPIOC, GPIO_Pin_7);
  10. }
  11. static void ad5290_spi_cs1(unsigned char state)
  12. {
  13.         if (state)
  14.                 GPIO_SetBits(GPIOC, GPIO_Pin_9);
  15.     else
  16.                 GPIO_ResetBits(GPIOC, GPIO_Pin_9);
  17. }
  18. static void ad5290_spi_cs2(unsigned char state)
  19. {
  20.         if (state)
  21.                 GPIO_SetBits(GPIOA, GPIO_Pin_12);
  22.     else
  23.                 GPIO_ResetBits(GPIOA, GPIO_Pin_12);
  24. }

  25. //init
  26. void ad5290_init(void)
  27. {       
  28.         GPIO_InitTypeDef GPIO_InitStructure;
  29.        
  30.         //spi cs
  31.          RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA|RCC_APB2Periph_GPIOC,ENABLE);
  32.        
  33.         GPIO_InitStructure.GPIO_Pin = GPIO_Pin_7 | GPIO_Pin_9;
  34.         GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
  35.         GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
  36.         GPIO_Init(GPIOC, &GPIO_InitStructure);
  37.         GPIO_SetBits(GPIOC,GPIO_Pin_7);
  38.         GPIO_SetBits(GPIOC,GPIO_Pin_9);
  39.        
  40.         GPIO_InitStructure.GPIO_Pin = GPIO_Pin_12;
  41.         GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
  42.         GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
  43.         GPIO_Init(GPIOA, &GPIO_InitStructure);
  44.         GPIO_SetBits(GPIOA,GPIO_Pin_12);
  45.                 /*device init*/
  46.         stm32f1xx_spi_init(0,0,&spi_bus1,8);        /*spi bus init*/
  47.                 //device 0
  48.         ad5290_spi_dev[0].spi_cs = ad5290_spi_cs0;
  49.         ad5290_spi_dev[0].spi_bus = &spi_bus1;
  50.                 //device 1
  51.         ad5290_spi_dev[1].spi_cs = ad5290_spi_cs1;
  52.         ad5290_spi_dev[1].spi_bus = &spi_bus1;
  53.                         //device 2
  54.         ad5290_spi_dev[2].spi_cs = ad5290_spi_cs2;
  55.         ad5290_spi_dev[2].spi_bus = &spi_bus1;
  56. }

  57. /**
  58.   * [url=home.php?mod=space&uid=247401]@brief[/url]  set resistance out
  59.   * @param  \set_value limits from 0x00 to 0xff
  60.   *                        \index sensor num,1 or 2 or 3
  61.   * @retval None
  62.   */
  63. void ad5290_set_out(u8 set_value,u8 index)
  64. {
  65.         if(index < 1 || index > 3)
  66.                 return;
  67.         spi_send(&ad5290_spi_dev[index-1],&set_value,1);
  68. }       


AD5290 代码,接了3片,用的是以下spi封装代码,参考。
https://blog.csdn.net/qq_20553613/article/details/78998617
 楼主| chest20090909 发表于 2018-10-21 22:34 | 显示全部楼层
877049204 发表于 2018-10-21 12:27
数字电位器不能用万用表测阻值

请问怎么验证数字电位器驱动正确呢,是给数字电位器输入电压然后看抽头电压吗

评论

可以分压测电压。数字电位器本来就是带电的,万用表测电阻不能带电测  发表于 2018-10-22 16:03
您需要登录后才可以回帖 登录 | 注册

本版积分规则

121

主题

632

帖子

4

粉丝
快速回复 在线客服 返回列表 返回顶部