sbit SCLK5615=P1^3;
sbit DA
sbit CS5615=P1^1;
void tlc5615(unsigned int dat); // TLC5615 conversion function
void delaynms(unsigned char k); // ms delay function
void main()
{
delaynms(200);
tlc5615(100); // Conversion output voltage = 2*Vref*code
while(1);
}
void tlc5615(unsigned int dat)
{
unsigned char i;
CS5615=1;
DA
SCLK5615=0; // During CS high level, SCLK is low level
dat<<=6; // Shift the digital quantity dat left by 6 bits, and keep the lower 10 bits of the original dat. The upper 10 bits of the new dat are valid, and the lower 6 bits are all 0.
CS5615=0; // CS chip select is valid, start receiving data
SCLK5615=0;
for(i=0;i<12;i++) // Send 10 bits of data and 2 bits of 0, starting from the highest bit.
{ // Non-cascade mode, only 12 bits of data need to be input.
if((dat&0x8000)==0x8000)
DA
else
DA
SCLK5615=1; // SCLK rising edge, data input
dat<<=1;
SCLK5615=0; // SCLK returns to low level
}
CS5615=1; // CS rising edge, data sent to DAC register
// The rising and falling edges of CS are only valid when SCLK is low
SCLK5615=0;
DA
}
void delaynms(unsigned char k) //Delay n ms
{
while(k)
{
int i;
i=110;
while(i--);
k=k-1;
}
}
Previous article:93C46 Read and Write 51 Programs
Next article:12864 graphic dot matrix LCD display module 51 program
- Popular Resources
- Popular amplifiers
- Siemens Motion Control Technology and Engineering Applications (Tongxue, edited by Wu Xiaojun)
- MCU C language programming and Proteus simulation technology (Xu Aijun)
- ATmega16 MCU C language programming classic example (Chen Zhongping)
- 51 Single Chip Microcomputer C Language Programming Classic Examples (2nd Edition) (Hou Yubao)
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- LED chemical incompatibility test to see which chemicals LEDs can be used with
- Application of ARM9 hardware coprocessor on WinCE embedded motherboard
- What are the key points for selecting rotor flowmeter?
- LM317 high power charger circuit
- A brief analysis of Embest's application and development of embedded medical devices
- Single-phase RC protection circuit
- stm32 PVD programmable voltage monitor
- Introduction and measurement of edge trigger and level trigger of 51 single chip microcomputer
- Improved design of Linux system software shell protection technology
- What to do if the ABB robot protection device stops
- Huawei's Strategic Department Director Gai Gang: The cumulative installed base of open source Euler operating system exceeds 10 million sets
- Download from the Internet--ARM Getting Started Notes
- Learn ARM development(22)
- Learn ARM development(21)
- Learn ARM development(20)
- Learn ARM development(19)
- Learn ARM development(14)
- Learn ARM development(15)
- Analysis of the application of several common contact parts in high-voltage connectors of new energy vehicles
- Wiring harness durability test and contact voltage drop test method