TLC549 CVAVR Program

Publisher:RadiantGlowLatest update time:2016-10-30 Source: eefocusKeywords:tlc549 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere
//Serial digital tube displays tlc549 AD conversion value

// Chip ATMEGA16L 
// Clock 4MHz internal
// Use system built-in delay program

#include  
#include

#define hc164_da ta PORTD.0 // 164 data line
#define hc164_clk PORTD.1 // 164 clock line
 
#define CLK549 PORTD.4 // tlc549 clock line, PD4 output
#define DA TA549 PIND.5 // tlc549 data line, PD5 input
#define CS549 PORTD.6 // tlc549 chip select line, PD6 output

void hc164_send_byte (unsigned char byte); // 164 output subroutine
void leddisplay (void); // digital tube display subroutine
unsigned char TLC549_ADC (void); //AD conversion subroutine

unsigned char ledxs[8]={16,16,16,16,16,0,0,0}; // Digital tube display buffer
                // AD conversion value hundreds, tens, and units  
flash unsigned char tab[]={0xb7,0x12,0x67,0x76,0xd2,0xf4,0xf5,0x16,0xf7,0xf6,0xd7,0xf1,0xa5,0x73,0xe5,0xc5,0,0xff};
                          // Common cathode code 0-F, all off, all on
void main()
{
   unsigned char ad_value,temp,j;   
   j=1;while(--j); // One cycle 11 cycles, 4M crystal oscillator, delay 2.75us
   delay_ms(200);  
   DDRD = 0x53; // PD0, PD1 (164 driver) are set to output mode;  
                         // PD4, PD6 (tlc549 clock and chip select) are set to output mode, PD5 (tlc549 data line) is set to input mode
   while(1)
   {
     ad_value = TLC549_ADC(); //Read AD conversion value
     temp = ad_value/100;
     ledxs[5] = temp; //Get the AD conversion value hundreds digit
     temp = ad_value%100;
     ledxs[6] = temp/10; //Get the AD conversion value tens digit
     ledxs[7] = temp%10; //Get the AD conversion value ones digit
     leddisplay(); //Serial display
     delay_ms(1000);
   }
}
unsigned char TLC549_ADC(void)
{
      unsigned char value=0;
      unsigned char i,j;
      CS549=1;  
      j=2;while(--j);
      CLK549=0;
      j=2;while(--j);
      CS549=0; //Chip start
      j=2;while(--j); //Wait for delay
      for(i=0;i<8;i++) //Input sampling conversion clock (pre-sampling)
      {
         CLK549=1;
         j=1;while(--j);
         CLK549=0;  
         j=1;while(--j);
      }
      CS549=1; //Start conversion
      j=10;while(--j); //Wait for conversion to end

      CLK549=0;
      j=2;while(--j);
      CS549=0; //Start reading the conversion result
      j=2;while(--j);
      for(i=0;i<8;i++) // Read sample value
      {
         CLK549=1;
         j=1;while(--j);
         value<<=1;
         value|=DA TA549;
         CLK549=0;  
         j=1;while(--j);
      }
      CS549=1;
      j=10;while(--j);
      return(value); //Return the conversion result
}
void leddisplay() // Digital tube display subroutine
{
  unsigned char i;
  for(i=0;i<8;i++)
  {
     hc164_send_byte (tab[ledxs[i]]);
     delay_us(2);
  }

void hc164_send_byte (unsigned char byte) // 164 output subroutine
{
  unsigned char i;
   for(i=0;i<8;i++)
   {
      hc164_da ta = byte & ( 1 << i );       
      hc164_clk = 1;       
      hc164_clk = 0;   
   }  
}  

Keywords:tlc549 Reference address:TLC549 CVAVR Program

Previous article:tlc1549 CVAVR Program
Next article:DS1302 CVAVR 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

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号