ADC0832 analog-to-digital conversion MSP430 microcontroller program + circuit diagram

Publisher:平稳心绪Latest update time:2015-06-18 Source: 51heiKeywords:ADC0832 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere
Here is the circuit diagram:



 


                ADC0832 package diagram          ADC0832 and microcontroller connection diagram ADC0832 timing diagram Program source code download:  http://www.51hei.com/f/0832430.rar #include #define DO (P1IN&BIT7) #define uchar unsigned char #define uint unsigned int[page] /*********************************************** sbit cs=P2^0; sbit clk=P2^1; sbit DI=P2^2; sbit DO=P2^6; *************************************************/ uint adval; uchar temp; uchar tab[]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90}; void delay(uint ms) {          uchar j;    while(ms--)    {      for(j=0;j<120;j++);    } }   void ADC_start() {  P2OUT|=BIT0;//cs=1  _NOP();  P2OUT&=~BIT1;//clk=0  _NOP();  P2OUT&=~BIT0;//cs=0  _NOP();  P2OUT|=BIT 2;//DI=1  _NOP();  P2OUT|=BIT1;//clk=1  _NOP();  P2OUT&=~BIT2;//DI=0;  _NOP();  P2OUT&=~BIT1;//clk=0;  _NOP(); } void ADC_read(uint CH) {   uchar i;   ADC_start();   if(CH==0) //Select channel 0         {           P2OUT|=B IT2;// DI=1;           P2OUT |=BIT1;//clk=1;                   _NOP();           _NOP();           P2OUT &=~BIT1;//clk=0;//The first falling edge comes DI=1           _NOP();           _NOP();            P2OUT |=BIT2;//DI=0;            P2OUT |=BIT1;//clk=1;           _NOP();            _NOP();                    P2OUT&=~BIT1;//clk=0;//The second falling edge comes DI=0, DI is 10 twice, select ch0 channel           _NOP();           _NOP();         }         else //Select channel 1          {           P2OUT|=BIT2;// DI=1;           P2OUT |=BIT1;//clk=1;                   _NOP();           _NOP();           P2OUT &=~BIT1;//clk=0;//The first falling edge comes DI=1           _NOP();           _NOP();            P2OUT |=BIT2;//DI=1;            P2OUT |=BIT1;//clk=1;           _NOP();            _NOP();                    P2OUT&=~BIT1;//clk=0;//The second falling edge comes DI=0, DI is 11 twice, select ch1 channel_NOP           ();           _NOP();           }   /****************Read data on the falling edge*******************/           P2OUT|=BIT1;//clk=1;           _NOP();           P2OUT&=~BIT1;//clk=0;Read data on the falling edge againfor           (i=0;i<8;i++)








 

















































































          {
             P2OUT|=BIT2;// DI=1;
              if(DO) // 检查DO;
                {
                 temp |=0x01;
                }
             else
                {
                 temp &=0xfe;
                }
             P2OUT&=~BIT1;//clk=0;
             _NOP();
             _NOP();
              P2OUT|=BIT1;//clk=1;//rising edge, shift left by 1 bit
             temp=temp<<1;
           }
   adval=temp;
 }
/********Display data********************************/
void display(uint dat)
{    
   P2OUT &=~BIT3;//Turn off the ones digit display P2.3
   P2OUT &=~BIT4;//Turn off the tens digit display P2.4
   P2OUT |=BIT5;//Turn on the hundreds digit display P2.5
   P1OUT=tab[dat/100];
   delay(1);
   P1OUT=0xff;
   P2OUT &=~BIT3;//turn off the ones digit display P2.3
   P2OUT |=BIT4;//turn on the tens digit display P2.4
   P2OUT &=~BIT5;//turn off the hundreds digit display P2.5
   P1OUT=tab[(dat%100)/10];
   delay(1);
   P1OUT=0xff;
   P2OUT |=BIT3;//turn on the ones digit display P2.3
   P2OUT &=~BIT4;//turn off the tens digit display P2.4
   P2OUT &=~BIT5;//turn off the hundreds digit display P2.5
   P1OUT=tab[dat/10];
   delay(1);
   P1OUT=0xff;
}
void main()
{
  
  WDTCTL = WDTPW + WDTHOLD;
  P2DIR =0x3f;  
  P1DIR|=0x7f;
   while(1)
   {
         ADC_read(0);
         delay(1);
         display(adval);
   }
}
Keywords:ADC0832 Reference address:ADC0832 analog-to-digital conversion MSP430 microcontroller program + circuit diagram

Previous article:Msp430 microcontroller flashing light program
Next article:Stepper motor driver assembly program and debugging summary

Recommended ReadingLatest update time:2024-11-23 08:42

Multi-channel resistance measurement system based on MSP430F169
Aiming at the problem of multi-channel resistance measurement difficulty often encountered in actual measurement work, a new multi-channel resistance measurement system is designed. The system uses two MSP430F169 microcontrollers to coordinate work, which improves the accuracy and stability of measurement. The slave
[Analog Electronics]
Multi-channel resistance measurement system based on MSP430F169
MSP430 Study Notes 6- Dynamic Digital Tube Display
I rewrote the main part of this program. The program uses the watchdog as a normal timer and scans the digital tubes in the watchdog interrupt. In addition, I added a display buffer. If you want to display a number on the digital tube, you only need to operate the value in the buffer array. Finally, I added the decima
[Microcontroller]
MSP430: PWM Generation
#define     PWM                      BIT6 //  Description: This program generates one PWM output on P1.2 or P1.6 using //  Timer_A configured for up mode. The value in CCR0, 25-1, defines the PWM //  period and the value in CCR1 the PWM duty cycles. //  A 50% duty cycle on P1.6. //  ACLK = na, SMCLK = MCLK = TACLK = d
[Microcontroller]
MSP430: PWM Generation
MSP430 Flowing Light Ⅰ
#include msp430f149.h      unsigned char LED;      unsigned int table = {BIT0,BIT1,BIT2,BIT3,BIT4,BIT5,BIT6,BIT7};      void main( void )   {     // Stop watchdog timer to prevent time out reset     WDTCTL = WDTPW + WDTHOLD;     LED = 0XFF;     P2DIR = 0XFF;     P2OUT = LED;     while(1)     {       unsigned int i,j;
[Microcontroller]
MSP430 flash operation
Today, I studied the flash operation of msp430. Many people may read my blog and find that many people on the website have summarized it better than me. I admit this because my ability is limited. However, from this blog, I will refer to the blogs written by the masters in the past, add the links of the blogs written
[Microcontroller]
Application of MSP430F in ETC of highway non-stop toll collection system
       TI's MSP430 microcontroller product series has a 16-bit RSIC architecture and ultra-low power consumption. As the latest product series of MSP430, F5xxx uses 0.18um process for the first time, and the current consumed by 1MIPs is as low as an astonishing 160uA, and the main frequency reaches 25MIPs. At the same
[Microcontroller]
Application of MSP430F in ETC of highway non-stop toll collection system
MSP430: Serial Output
initialization  1 void Uart_Init(void)  2 {  3       BCSCTL1 = CALBC1_1MHZ;                    // Set DCO  4       DCOCTL = CALDCO_1MHZ;  5       P1SEL = BIT1 + BIT2 ;                     // P1.1 = RXD, P1.2=TXD  6       P1SEL2 = BIT1 + BIT2 ;                    // P1.1 = RXD, P1.2=TXD  7       UCA0CTL1 |= UCSSEL_2
[Microcontroller]
Temperature alarm system based on MSP430 embedded temperature sensor
1. Overall plan of the system The MSP430 microcontroller MCU (Micro Controller Unit) is an ultra-low power 16-bit mixed signal processor launched by TI with rich on-chip peripherals and powerful functions. It includes a series of devices that can be used in different occasions. A significant difference betw
[Industrial Control]
Temperature alarm system based on MSP430 embedded temperature sensor
Latest Microcontroller Articles
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号