51 programs of TLC5615

Publisher:科技先锋Latest update time:2016-10-30 Source: eefocusKeywords:TLC5615 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere
#include

sbit SCLK5615=P1^3;
sbit DA TA5615=P1^2;
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 /1024, the maximum output voltage is the power supply voltage.
  while(1);

}
void tlc5615(unsigned int dat)
{
  unsigned char i;
  CS5615=1;
  DA TA5615=0;    
  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 TA5615=1;
    else
      DA TA5615=0;
    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 TA5615=0; // Pull up the chip select end, pull down the clock end and data end, and return to the initial state
}
void delaynms(unsigned char k) //Delay n ms
{
  while(k)
  {
  int i;
  i=110;
  while(i--);
  k=k-1;
  }
}

Keywords:TLC5615 Reference address:51 programs of TLC5615

Previous article:93C46 Read and Write 51 Programs
Next article:12864 graphic dot matrix LCD display module 51 program

Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
Change More Related Popular Components
Guess you like

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号