//Note: Vref and Vout should be connected together when debugging
#include "reg51.h"
sbit MAX532_CS=P1^0;
sbit MAX532_DIN=P1^1;
sbit MAX532_SCLK=P1^2;
void MAX532_OUT(unsigned char daout1,unsigned char daout2,unsigned char daout3);
void delay()
{
unsigned int i,j;
for(i=0;i<1000;i++)
for(j=100;j>0;j--)
;
}
void main(void)
{
while(1)
{
MAX532_OUT(0x80,0x08,0x00); // 1/2 Vref
MAX532_OUT(0x80,0x08,0x00); // 1/2 Vref
MAX532_OUT(0x80,0x08,0x00); // 1/2 Vref
}
}
// In order to ensure the DA output speed, the method of sending data directly is adopted
void MAX532_OUT(unsigned char daout1,unsigned char daout2,unsigned char daout3)
{
//MAX532_CS=1;
//MAX532_DIN
=1 ; //
MAX532_SCLK=1; MAX532_CS
=0; MAX532_SCLK=0;
MAX532_DIN=(bit)(daout1&0x80);
MAX532_SCLK=1;
MAX532_SCLK=0;
MAX532_DIN=(bit)(daout1&0x40);
MAX532_SCLK=1;
MAX532_SCLK=0;
MAX532_DIN=(bit)(daout1&0x20);
MAX532_SCLK=1;
MAX532_SCLK=0;
MAX532_DIN=(bit)(daout1&0x10);
MAX532_SCLK=1;
MAX532_SCLK=0;
MAX532_DIN=(bit)(daout1&0x08);
MAX532_SCLK=1;
MAX532_SCLK=0;
MAX532_DIN=(bit)(daout1&0x04);
MAX532_SCLK=1 ;
MAX532_SCLK=0;
MAX532_DIN=(bit)(daout1&0x02);
MAX532_SCLK=1;
MAX532_SCLK=0;
MAX532_DIN=(bit)(daout1&0x01);
MAX532_SCLK=1;
MAX532_SCLK=0;
MAX532_DIN=(bit)(daout2&0x80) ;
MAX532_SCLK=1;
MAX532_SCLK=0;
MAX532_DIN=(bit)(daout2&0x40);
MAX532_SCLK=1;
MAX532_SCLK=0;
MAX532_DIN=(bit)(daout2&0x20);
MAX532_SCLK=1;
MAX532_SCLK=0;
MAX532_DIN=(bit)(daout2&0x10);
MAX532_SCLK=1;
MAX532_SCLK=0;
MAX532_DIN=(bit)(daout2&0x08);
MAX532_SCLK=1;
MAX532_SCLK=0;
MAX532_DIN=(bit)(daout2&0x04);
MAX532_SCLK=1;
MAX532_SCLK=0;
MAX532_DIN=(bit)(daout2&0x02);
MAX532_SCLK=1;
MAX532_SCLK=0;
MAX532_DIN=(bit)(daout2&0x01);
MAX532_SCLK=1;
MAX532_SCLK=0;
MAX532_DIN=(bit)(daout3&0x80);
MAX532_SCLK=1 ;
MAX532_SCLK=0;
MAX532_DIN=(bit)(daout3&0x40);
MAX532_SCLK=1;
MAX532_SCLK=0;
MAX532_DIN=(bit)(daout3&0x20);
MAX532_SCLK=1;
MAX532_SCLK=0;
MAX532_DIN=(bit)(daout3&0x10) ;
MAX532_SCLK=1;
MAX532_SCLK=0;
MAX532_DIN=(bit)(daout3&0x08);
MAX532_SCLK=1;
MAX532_SCLK=0;
MAX532_DIN=(bit)(daout3&0x04);
MAX532_SCLK=1;
MAX532_SCLK=0;
MAX532_DIN=(bit )(daout3&0x02);
MAX532_SCLK=1;
MAX532_SCLK=0;
MAX532_DIN=(bit)(daout3&0x01);
MAX532_SCLK=1;
MAX532_CS=1;
}
Previous article:DS12887 (clock calendar chip) C language driver
Next article:X25045 Driver
- Popular Resources
- Popular amplifiers
- Learn ARM development(16)
- Learn ARM development(17)
- Learn ARM development(18)
- Embedded system debugging simulation tool
- A small question that has been bothering me recently has finally been solved~~
- Learn ARM development (1)
- Learn ARM development (2)
- Learn ARM development (4)
- Learn ARM development (6)
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
- From probes to power supplies, Tektronix is leading the way in comprehensive innovation in power electronics testing
- From probes to power supplies, Tektronix is leading the way in comprehensive innovation in power electronics testing
- Sn-doped CuO nanostructure-based ethanol gas sensor for real-time drunk driving detection in vehicles
- Design considerations for automotive battery wiring harness
- Do you know all the various motors commonly used in automotive electronics?
- What are the functions of the Internet of Vehicles? What are the uses and benefits of the Internet of Vehicles?
- Power Inverter - A critical safety system for electric vehicles
- Analysis of the information security mechanism of AUTOSAR, the automotive embedded software framework
- Brief Analysis of Automotive Ethernet Test Content and Test Methods
- How haptic technology can enhance driving safety
- LLC circuit dead time
- Reconstructing the antenna design solution for mobile devices in the 5G era
- What exactly are those “special pads” on PCB boards used for?
- CC2640 power configuration modification
- Is there a conflict between CircuitPython and MicroPython?
- What is the relationship between embedded and microcontroller?
- Problems encountered in debugging Pingtouge's scenario-based Bluetooth Mesh
- Can S0 on the coil be understood as an ordinary auxiliary relay?
- Noise Suppression Basics Tutorial - Noise Suppression in Differential Transmission
- What content do you most want to see about Bluetooth?