驱动程序——TLC7226——基于STM32F103
来源:互联网 发布:公司logo在线制作软件 编辑:程序博客网 时间:2024/06/05 03:11
TLC7226 8 位,5us 四路 DAC,并行输入、单/双电源
时序图:
void IO_Configuration(void)
{
GPIO_InitTypeDef GPIO_InitStructure;
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA
|RCC_APB2Periph_GPIOB
|RCC_APB2Periph_GPIOC,ENABLE);
GPIO_InitStructure.GPIO_Pin=Relays1_0|Relays1_1|Relays1_2
|Relays2_0|Relays2_1|Relays2_2
|Relays3_0|Relays3_1|Relays3_2
|Relays4_0|Relays4_1|Relays4_2;
GPIO_InitStructure.GPIO_Mode=GPIO_Mode_Out_PP;
GPIO_InitStructure.GPIO_Speed=GPIO_Speed_50MHz;
GPIO_Init(Relays_PORT,&GPIO_InitStructure);
GPIO_Init(Beep_PORT,&GPIO_InitStructure);
GPIO_InitStructure.GPIO_Pin=DAC1_A0|DAC1_A1|DAC1_WR|DAC2_A0|DAC2_A1|DAC2_WR;
GPIO_InitStructure.GPIO_Mode=GPIO_Mode_Out_PP;
GPIO_InitStructure.GPIO_Speed=GPIO_Speed_50MHz;
GPIO_Init(DAC_CS_PORT,&GPIO_InitStructure);
GPIO_InitStructure.GPIO_Pin=DAC_D0|DAC_D1|DAC_D2|DAC_D3|DAC_D4|DAC_D5|DAC_D6|DAC_D7;
GPIO_InitStructure.GPIO_Mode=GPIO_Mode_Out_PP;
GPIO_InitStructure.GPIO_Speed=GPIO_Speed_50MHz;
GPIO_Init(DAC_DATA_PORT,&GPIO_InitStructure);
//
}
void DAC_Config(unsigned char ch,unsigned char value)
{
if(ch<4)
GPIO_SetBits(DAC_CS_PORT,DAC1_WR);
else
GPIO_SetBits(DAC_CS_PORT,DAC2_WR);
switch(ch)
{
case 0:
GPIO_ResetBits(DAC_CS_PORT,DAC1_A0);
GPIO_ResetBits(DAC_CS_PORT,DAC1_A1);
break;
case 1:
GPIO_SetBits(DAC_CS_PORT,DAC1_A0);
GPIO_ResetBits(DAC_CS_PORT,DAC1_A1);
break;
case 2:
GPIO_ResetBits(DAC_CS_PORT,DAC1_A0);
GPIO_SetBits(DAC_CS_PORT,DAC1_A1);
break;
case 3:
GPIO_SetBits(DAC_CS_PORT,DAC1_A0);
GPIO_SetBits(DAC_CS_PORT,DAC1_A1);
break;
case 4:
GPIO_ResetBits(DAC_CS_PORT,DAC2_A0);
GPIO_ResetBits(DAC_CS_PORT,DAC2_A1);
break;
case 5:
GPIO_SetBits(DAC_CS_PORT,DAC2_A0);
GPIO_ResetBits(DAC_CS_PORT,DAC2_A1);
break;
case 6:
GPIO_ResetBits(DAC_CS_PORT,DAC2_A0);
GPIO_SetBits(DAC_CS_PORT,DAC2_A1);
break;
case 7:
GPIO_SetBits(DAC_CS_PORT,DAC2_A0);
GPIO_SetBits(DAC_CS_PORT,DAC2_A1);
break;
}
Delay(10);
if(ch<4)
GPIO_ResetBits(DAC_CS_PORT,DAC1_WR);
else
GPIO_ResetBits(DAC_CS_PORT,DAC2_WR);
Delay(10);
//for()
GPIO_SetBits(DAC_DATA_PORT, (value & 0xff)<<8);
GPIO_ResetBits(DAC_DATA_PORT, (~value & 0xff)<<8);
Delay(10);
if(ch<4)
GPIO_SetBits(DAC_CS_PORT,DAC1_WR);
else
GPIO_SetBits(DAC_CS_PORT,DAC2_WR);
Delay(10);
}
- 驱动程序——TLC7226——基于STM32F103
- 驱动程序——MAX6675——基于STM32F103
- 驱动程序——MCP4922——基于STM32F103
- STM32f103——ILI9341
- STM32f103 —— timer
- STM32f103 —— can通信
- stm32f103学习笔记——NVIC初始化
- STM32F103学习笔记——仿真波形
- STM32F103学习笔记——SysTick
- STM32F103学习笔记——外部中断
- STM32F103学习笔记——串口通信
- STM32f103 —— 内部flash读写
- 1.STM32F103学习——GPIO之点亮小灯
- stm32f103学习笔记——关键字extern、static、const
- STM32F103学习笔记——时钟使能
- STM32F103按键操作的另一种实现——状态机
- STM32F103+RTT从零开始(一)——点亮LED
- STM32F103+RTT从零开始(一)——点亮LED
- linux mysql 授权
- socket通信之http-server
- BZOJ4886: [Lydsy2017年5月月赛]叠塔游戏
- 虚拟机类加载机制
- Jsp+Hibernate开发中遇到的问题 java.lang.ClassNotFoundException: org.hibernate.Session的解决
- 驱动程序——TLC7226——基于STM32F103
- 完成输入框自动切换对应的中文或英文输入法
- Office 常用技巧
- 通过ssh协议连接服务器失败
- 二分查找
- [torch] remove layers from the model
- Kotlin编程开发Android运用程序(Volley+Gson依赖库)
- Java总哈希表的运用,判断一个数组中是否存在相同的元素之间的距离在k以内!
- 简明C语言教程(二十一)自增自减运算符