Etiquetas

555 74HC04 74HC14 74HC165 74LS04 acentos ADC10 Amstrad archivo arduino aristóteles armbian array ass at backup base64 bash Basho bc beethoven Biblia blog bucle c c++ c++11 c++17 C005 cadena Carmina Burana casting CD4017 CD4040 Cine clases Colores connect Consolación a Helvia Consolación a Marcia Consolación a Polibio constante corsair CPC Cristal 32Khz css cursor mouse cut daemon date dead keys Debian directorio disco duro DS32kHz electricidad Electrónica ensamblador entryList epicureismo Estadística estoicismo felicidad ffmpeg filePath filosofia Filosofía firefox flac for fstab funcion Gargantúa gastronomía gilgamesh Ginott gmp gpt grep gtts Hobbes hotkeys html imagemagick inline Javascript kde kernel modulos latex ldr lib-notify Linux Literatura ludoteca macro mapa de bits Matroska mega Microsoft Word Milan Kundera mkvextract mkvinfo mount mp3 mplayer MSP430 msp430F5529 MSP432 Multimedia Musica oop orange_pi pato PIR PL9823 Platón poesía POO en C++ pulseaudio puntero PWM pygame pyqt python QAction qApp QApplication QByteArray QDialog Qdir QFile QFileDialog QImage qlabel QList QListWidget QMessagebox QMouseEvent qpainter QPalette QPixmap QProcess QRegularExpression QRegularExpressionMatchIterator QString QStringList Qt qt5 QToolbar quijote QVector qwidget R Rabelais ratón relé Resonador cerámico samba San Agustín screen Séneca signal slot smart smartctl sox srt static const stdarg.h subtítulos Symbian tar teléfonos móviles temperatura temperatura cpu Temporizador tesseract Timer timestamp Trigonometría tts tutorial uid unicode user USI va_arg va_end va_list va_start velocidad ventilador Voltaire wallpaper xboxdrv xinput xrandr Z80 zip

martes, mayo 21, 2013

ADC10 en el MSP430

El ADC10 se pone en modo automático continuo. El valor de ADC10MEM se lee cada 500 ms. con el temporizador.

main.c
#include <msp430.h>
#include <ti/mcu/msp430/Grace.h>

/*
 *  ======== main ========
 */
int main(void)
{
    Grace_init();                   // Activate Grace-generated configuration
    ADC10CTL0 |= ADC10SC;    // comenzar conversion
    __bis_SR_register(LPM3 + GIE);
}


InterruptVectors_init.c
/*
 *  ======== Timer1_A3 Interrupt Service Routine ======== 
 */
#pragma vector=TIMER1_A0_VECTOR
__interrupt void TIMER1_A0_ISR_HOOK(void)
{
    /* USER CODE START (section: TIMER1_A0_ISR_HOOK) */
    P1OUT ^= BIT0;
 if (ADC10MEM < 512) {
  P2OUT |= BIT0;
  P2OUT &= ~BIT1;
 } else {
  P2OUT &= ~BIT0;
  P2OUT |= BIT1;
 }
    /* USER CODE END (section: TIMER1_A0_ISR_HOOK) */
}


ADC10_init.c
/*
 *  ======== ADC10_graceInit ========
 *  Initialize MSP430 10-bit Analog to Digital Converter
 */
void ADC10_graceInit(void)
{
    /* USER CODE START (section: ADC10_graceInit_prologue) */
    /* User initialization code */
    /* USER CODE END (section: ADC10_graceInit_prologue) */

    /* disable ADC10 during initialization */
    ADC10CTL0 &= ~ENC;

    /* 
     * Control Register 0
     * 
     * ~ADC10SC -- No conversion
     * ~ENC -- Disable ADC
     * ~ADC10IFG -- Clear ADC interrupt flag
     * ~ADC10IE -- Disable ADC interrupt
     * ADC10ON -- Switch On ADC10
     * REFON -- Enable ADC reference generator
     * ~REF2_5V -- Set reference voltage generator = 1.5V
     * MSC -- Enable multiple sample and conversion
     * ~REFBURST -- Reference buffer on continuously
     * ~REFOUT -- Reference output off
     * ~ADC10SR -- Reference buffer supports up to ~200 ksps
     * ADC10SHT_0 -- 4 x ADC10CLKs
     * SREF_1 -- VR+ = VREF+ and VR- = VSS
     * 
     * Note: ~<BIT> indicates that <BIT> has value zero
     */
    ADC10CTL0 = ADC10ON + REFON + MSC + ADC10SHT_0 + SREF_1;

    /* 
     * Control Register 1
     * 
     * ~ADC10BUSY -- No operation is active
     * CONSEQ_2 -- Repeat single channel
     * ADC10SSEL_0 -- ADC10OSC
     * ADC10DIV_0 -- Divide by 1
     * ~ISSH -- Input signal not inverted
     * ~ADC10DF -- ADC10 Data Format as binary
     * SHS_0 -- ADC10SC
     * INCH_1 -- ADC Channel 1
     * 
     * Note: ~<BIT> indicates that <BIT> has value zero
     */
    ADC10CTL1 = CONSEQ_2 + ADC10SSEL_0 + ADC10DIV_0 + SHS_0 + INCH_1;

    /* Analog (Input) Enable Control Register 0 */
    ADC10AE0 = 0x2;

    /* Software delay for REFON to settle */
    __delay_cycles(30000);

    /* enable ADC10 */
    ADC10CTL0 |= ENC;

    /* USER CODE START (section: ADC10_graceInit_epilogue) */
    /* User code */
    /* USER CODE END (section: ADC10_graceInit_epilogue) */
}


main.cfg



Esquema

No hay comentarios: