841336876

    1. 楼上说得有道理
    2. 求教关于温湿度传感器的安装方式 16/6538 传感器 2012-05-22
      把18B20加工成那种跟,PT100一样的金属头:Laugh: ????
    3. 看看
    4. 消费电子领域十大技术趋势 1057/134096 消费电子 2012-05-21
      看看
    5. 呵呵,什么公司啊!
    6. 国外牛人自制风力发电机全过程 3/4664 能源基础设施 2012-04-19
      呵呵,不是没有兴趣,是没有钱不行吧!!!!!!!!!!哈哈哈:lol
    7. 已经笑死9999个了,您千万不要做第10000个! 397/51870 聊聊、笑笑、闹闹 2012-04-12
      估计是标题党吧
    8. 电源设计细节大全 45/13140 电源技术 2012-04-12
      谢谢楼主的分享。。。。。。。
    9. 我用了一个小的板子,把各个管脚转换成了直插的 嘿嘿 挺方便的
    10. 求助 1/2324 嵌入式系统 2012-04-09
      我也在弄这个芯片呢:)
    11. 单片机多机通讯 10/5153 51单片机 2012-04-06
      每个单片机,自定义一个唯一的 地址
    12. 数码管,点阵的问题。(小白求助) 17/6775 51单片机 2012-04-06
      那是 限制流回单片机的电流,限流电阻都是一端接VCC,一端接单片机。单片机输出高电平时候 可以增加带负载能力,输出低电平时候,防止大量电流流入单片机
    13. 8051单片机彻底研究 38/10874 51单片机 2012-04-06
      做个记号1
    14. Proteus系列软件大全 4/3440 51单片机 2012-04-06
      :victory: 做个记号
    15. C专家编程.pdf 74/17949 51单片机 2012-04-06
      谢谢分享
    16. DXP设计100例 90/17141 51单片机 2012-04-06
      那么我就收下了,谢谢楼主了!
    17. 确实有些问题,lz有心了。
    18. C51使用技巧及实战 9/4731 51单片机 2012-04-06
      呵呵,我用C。一般不用汇编
    19. //----------------------------------------------------------------------------- // F35x_ADC0_ExternalInput.c //----------------------------------------------------------------------------- // Copyright 2006 Silicon Laboratories, Inc. // http://www.silabs.com // // Program Description: // -------------------- // // This example code for the C8051F350 takes measurements from input A1N0.2 // using ADC0 then prints the results to a terminal window via the UART. // // The system is clocked by the internal 24.5MHz oscillator. The completion of // this conversion in turn triggers an interrupt service routine (ISR). The ISR // calculates the ADC0 result into the equivalent mV and then prints the value // to the terminal via printf before starting another conversion. // // The analog multiplexer selects A1N2 as the positive ADC0 input.  This // port is configured as an analog input in the port initialization routine. // The negative ADC0 input is connected via mux to ground, which provides // for a single-ended ADC input. // // A 100kohm potentiometer may be connected as a voltage divider between // VREF and AGND on the terminal strip as shown below: // // --------- //          | //         o| VREF ----| //         o| GND   ---| select Microcontrollers under "Products at the top) and // clicking the gray link on the left. // // Direct link: //   http://www.silabs.com/products/microcontroller/applications.asp // // F350 Resources: // --------------- // Timer1: clocks UART // // How To Test: // ------------ // 1) Download code to a 'F350 device on a C8051F350-TB development board // 2) Connect serial cable from the transceiver to a PC // 3) On the PC, open HyperTerminal (or any other terminal program) and connect //    to the COM port at and 8-N-1 // 4) Connect a variable voltage source (between 0 and Vref) //    to AIN2, or a potentiometer voltage divider as shown above. // 5) HyperTerminal will print the voltage measured by the device. // // FID:            35X000029 // Target:         C8051F350 // Tool chain:     Keil C51 7.50 / Keil EVAL C51 // Command Line:   None // // Release 1.0 //    -Initial Revision (SM / TP) //    - 8 NOV 2006 //----------------------------------------------------------------------------- // Includes //----------------------------------------------------------------------------- #include                  // SFR declarations #include //----------------------------------------------------------------------------- // 16-bit SFR Definitions for 'F35x //----------------------------------------------------------------------------- sfr16 TMR2RL = 0xCA;                   // Timer2 reload value sfr16 TMR2 = 0xCC;                     // Timer2 counter sfr16 ADC0DEC = 0x9A;                  // ADC0 Decimation Ratio Register //----------------------------------------------------------------------------- // Global CONSTANTS //----------------------------------------------------------------------------- #define SYSCLK       24500000          // SYSCLK frequency in Hz #define MDCLK         2457600          // Modulator clock in Hz (ideal is                                        // (2.4576 MHz) #define OWR                20          // Desired Output Word Rate in Hz #define BAUDRATE       115200          // Baud rate of UART in bps sbit LED = P0^7;                       // LED='1' means ON sbit SW2 = P1^0;                       // SW2='0' means switch pressed typedef union LONGDATA{                // Access LONGDATA as an    unsigned long result;               // unsigned long variable or    unsigned char Byte[4];              // 4 unsigned byte variables }LONGDATA; // With the Keil compiler and union byte addressing: // [0] = bits 31-24, [1] =  bits 23-16, [2] = bits 15-8, [3] = bits 7-0 #define Byte3 0 #define Byte2 1 #define Byte1 2 #define Byte0 3 //----------------------------------------------------------------------------- // Function PROTOTYPES //----------------------------------------------------------------------------- void Oscillator_Init (void); void Port_Init (void); void UART0_Init (void); void ADC0_Init(void); //----------------------------------------------------------------------------- // MAIN Routine //----------------------------------------------------------------------------- void main (void) {    PCA0MD &= ~0x40;                    // WDTE = 0 (clear watchdog timer                                        // enable)    Oscillator_Init();                  // Initialize system clock    Port_Init();                        // Initialize Crossbar and GPIO    UART0_Init();                       // Initialize UART0 for printf's    ADC0_Init();                        // Initialize ADC0    AD0INT = 0;    ADC0MD = 0x83;                      // Start continuous conversions    EA = 1;                             // Enable global interrupts    while (1) {                         // Spin forever    } } //----------------------------------------------------------------------------- // Initialization Subroutines //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- // Oscillator_Init //----------------------------------------------------------------------------- // // Return Value : None // Parameters   : None // // This routine initializes the system clock to use the internal 24.5MHz // oscillator as its clock source.  Also enables missing clock detector reset. // //----------------------------------------------------------------------------- void Oscillator_Init (void) {    OSCICN = 0x83;                      // Configure internal oscillator for                                        // its lowest frequency    RSTSRC = 0x04;                      // Enable missing clock detector } //----------------------------------------------------------------------------- // Port_Init //----------------------------------------------------------------------------- // // Return Value : None // Parameters   : None // // This function initializes the GPIO and the Crossbar // // Pinout: // //   P0.4 - UART TX (digital, push-pull) //   P0.5 - UART RX (digital, open-drain) // //   AIN0.2 - ADC0 input // //----------------------------------------------------------------------------- void Port_Init (void) {    XBR0 = 0x01;                        // UART0 Selected    XBR1 = 0x40;                        // Enable crossbar and weak pull-ups    P0MDOUT |= 0xD0;                    // TX, LEDs = Push-pull } //----------------------------------------------------------------------------- // UART0_Init //----------------------------------------------------------------------------- // // Return Value : None // Parameters   : None // // Configure the UART0 using Timer1, for and 8-N-1. // //----------------------------------------------------------------------------- void UART0_Init (void) {    SCON0 = 0x10;                       // SCON0: 8-bit variable bit rate                                        //        level of STOP bit is ignored                                        //        RX enabled                                        //        ninth bits are zeros                                        //        clear RI0 and TI0 bits    if (SYSCLK/BAUDRATE/2/256 < 1) {       TH1 = -(SYSCLK/BAUDRATE/2);       CKCON |=  0x08;                  // T1M = 1; SCA1:0 = xx    } else if (SYSCLK/BAUDRATE/2/256 < 4) {       TH1 = -(SYSCLK/BAUDRATE/2/4);       CKCON &= ~0x0B;                  // T1M = 0; SCA1:0 = 01       CKCON |=  0x01;    } else if (SYSCLK/BAUDRATE/2/256 < 12) {       TH1 = -(SYSCLK/BAUDRATE/2/12);       CKCON &= ~0x0B;                  // T1M = 0; SCA1:0 = 00    } else if (SYSCLK/BAUDRATE/2/256 < 48) {       TH1 = -(SYSCLK/BAUDRATE/2/48);       CKCON &= ~0x0B;                  // T1M = 0; SCA1:0 = 10       CKCON |=  0x02;    } else {       while (1);                       // Error.  Unsupported baud rate    }    TL1 = TH1;                          // Init Timer1    TMOD &= ~0xf0;                      // TMOD: timer 1 in 8-bit autoreload    TMOD |=  0x20;    TR1 = 1;                            // START Timer1    TI0 = 1;                            // Indicate TX0 ready } //----------------------------------------------------------------------------- // ADC0_Init //----------------------------------------------------------------------------- // // Return Value : None // Parameters   : None // // Initialize the ADC to use the temperature sensor. (non-differential) // //----------------------------------------------------------------------------- void ADC0_Init (void) {    REF0CN |= 0x03;                     // Enable internal Vref    ADC0CN = 0x00;                      // Gain = 1, Unipolar mode    ADC0CF = 0x00;                      // Interrupts upon SINC3 filter output                                        // and uses internal VREF    ADC0CLK = (SYSCLK/MDCLK)-1;         // Generate MDCLK for modulator.                                        // Ideally MDCLK = 2.4576MHz    // Program decimation rate for desired OWR    ADC0DEC = ((unsigned long) MDCLK / (unsigned long) OWR /               (unsigned long) 128) - 1;    ADC0BUF = 0x00;                     // Turn off Input Buffers    ADC0MUX = 0x28;                     // Select AIN0.2    ADC0MD = 0x81;                      // Start internal calibration    while(AD0CALC != 1);                // Wait until calibration is complete    EIE1   |= 0x08;                     // Enable ADC0 Interrupts    ADC0MD  = 0x80;                     // Enable the ADC0 (IDLE Mode) } //----------------------------------------------------------------------------- // Interrupt Service Routines //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- // ADC0_ISR //----------------------------------------------------------------------------- // // This ISR prints the result to the UART. The ISR is called after each ADC // conversion. // //----------------------------------------------------------------------------- void ADC0_ISR (void) interrupt 10 {    static LONGDATA rawValue;    unsigned long mV;    while(!AD0INT);                     // Wait till conversion complete    AD0INT = 0;                         // Clear ADC0 conversion complete flag    // Copy the output value of the ADC    rawValue.Byte[Byte3] = 0x00;    rawValue.Byte[Byte2] = (unsigned char)ADC0H;    rawValue.Byte[Byte1] = (unsigned char)ADC0M;    rawValue.Byte[Byte0] = (unsigned char)ADC0L;    //                           Vref (mV)    //   measurement (mV) =   --------------- * result (bits)    //                       (2^24)-1 (bits)    //    //   measurement (mV) =  result (bits) / ((2^24)-1 (bits) / Vref (mV))    //    //    //   With a Vref (mV) of 2500:    //    //   measurement (mV) =  result (bits) / ((2^24)-1 / 2500)    //    //   measurement (mV) =  result (bits) / ((2^24)-1 / 2500)    //    //   measurement (mV) =  result (bits) / (16777215 / 2500)    //    //   measurement (mV) =  result (bits) / (6710)    mV = rawValue.result / 6710;        // Because of bounds issues, this                                        // calculation has been manipulated as                                        // shown above                                        // (i.e. 2500 (VREF) * 2^24 (ADC result)                                        // is greater than 2^32)    printf("AIN0.2 voltage: %4ld mV\n",mV); } //----------------------------------------------------------------------------- // End Of File //-----------------------------------------------------------------------------
    20. 先找一个能运行的AD程序,目前还未找到:Sad:

最近访客

< 1/1 >

统计信息

已有392人来访过

  • 芯积分:--
  • 好友:--
  • 主题:1
  • 回复:27

留言

你需要登录后才可以留言 登录 | 注册


现在还没有留言