Quantcast
Channel: MSP low-power microcontroller forum - Recent Threads
Viewing all 22212 articles
Browse latest View live

EVM430-FR6047: Differential ToF estimation using cross-correlation

$
0
0

Part Number:EVM430-FR6047

Hello,

I have found information about the cross-correlation method for determining the differential time of flight used in the EVM430-FR6047 demo in

TI Designs: TIDM-1019 Ultrasonic Sensing Subsystem Reference Design for Water Flow Measurement

www.ti.com/.../tidudn0.pdf

Page 8 & 9

as well as in

High precision & accurate sensing at lowest flow rate for metering applications

http://www.ti.com/lit/ml/swmp003/swmp003.pdf

Page 12 & 13

but the two write-ups seem to be conflicting in detail. Also the formatting of the first one is horrible. Because of this I have not yet understood what exactly is happening, so my question is: Is there a clean or more detailed write-up?

Thank you very much for your support.

Best regards

Daniel


CCS/MSP-EXP430G2: SPI or I2C example code for MSP430 to work with BME280

$
0
0

Part Number:MSP-EXP430G2

Tool/software: Code Composer Studio

Hello, 

 Now I am working with MSP430G2553 on G2 board to communicate with a BME280 pressure, temperature and humidity sensor which is from BOSCH. But now I am having some problems with my code. Can anyone please give me some example code in CCS for the communication by SPI or I2C. Thank you so much.

Best Regards,

Binh

 

MSP-GANG: MSP-GANG

$
0
0

Part Number:MSP-GANG

I updated the MSP-GANG programmer to version 1.02.10.00 and now it's not saving the files to memory. After removing the USB and connecting again I cannot load a file into my target.

MSP430G2533: How to use SoC to program MSP430G2533?

$
0
0

Part Number:MSP430G2533

Hi TI,

If I want to use SoC to program MSP430G2533, is it possible?

If it's possible, which interface(UART or I2C or SPI) can be done?

Could you please provide the hardware schematic? (what interface connect to which pin)

Please let me know your comment.

Thanks.

Eric

MSP430FR6047: Problems with the "USSLib_02_10_00_07"

$
0
0

Part Number:MSP430FR6047

hi,

When I tested "USSLib_02_10_00_07", I have some problems.

1. When I run the example project "Fr6047_ussswlib_template_example_devel" on my board, when I perform the "code = USS_verifyHSPLLFrequency(&gUssSWConfig, &testResults);" , the return code is "Uss_message_code _hspll_pll_unlock_error ".The results of the testResults are as follows:

2. Sometimes, it's halted at "commonTimerGenerateLowPowerDelay"  As follows:

The chip on my board is XMS430FR6047IPZR (Rev A),Is that the cause of the problem?

Best Regards,

Lucas

MSP430FR6047: Help for quick start of evm

$
0
0

Part Number:MSP430FR6047

Hello guys

My name is William, and I recently bought the EVM430FR6047 for water flow measurement. I've done the basics parameters with the USS design center program and try using, but It didn't work well. On error window, It says that there's no signal coming from the sensors. I connected them to the CH0 and CH1 pins, with their grounds properly connected too. 

Did I miss something? Do I need to upload some code to the board, or it's already programmed and ready to use? Thank you.

Best regards.

MSP430F5418A: Exiting while loop but interrupts firing properly?

$
0
0

Part Number:MSP430F5418A

Hi all,

I am having a strange issue where it seems that my infinite while loop is not executing properly but ISRs are triggering. I know this because I have a UART trace which dumps variables to a terminal. I increment these variables in infinite loop as well as various ISRs. The ones in ISRs constantly change while the ones in while loop stop after a short duration. I am not using any low power mode. Also, I am getting this problem intermittently and happens only at bootup. If the bootup sequence is complete the code runs fine. 

It seems to me that the code is either stuck in some kind of a trap ISR or a default handler. The trap ISR is written in ASM. How do I go about incrementing variables in this trap function so that I can request trace? 

Here's the skeleton of my code.

main()
{
    init_hw();
    __bis_SR_register(GIE); 
    while(1)
    {
        /*code/*
    }
}

timer_isr()
{
    code;
}

ADC_isr()
{
    code;
}

UART_isr()
{
    REQUEST_TRACE:
        TRANSMIT VARIABLES THROUGH UART;
}

What are the possibilities by which the code is not executing infinite while loop in main and what is the easiest way to debug without using the debugger?

Thanks!

  

MSP430F2274: Toggling LED with Timer_A in up/down mode.

$
0
0

Part Number:MSP430F2274

Hello, I am trying to configure the MSP430 device to toggle an LED utilizing Timer_A in up/down mode. I thought my code was correct, as it works when dealing with continuous mode, but after modifying the registers for up/down mode, the device does not work as predicted. My code is provided, thank you.

#include <msp430.h>

int main(void)
{
  WDTCTL = WDTPW + WDTHOLD;                 // Stop WDT
  P1DIR |= BIT0;                            // P1.1 output
  P1OUT &= ~BIT0;

  TACCR0 = 5;
  TACTL = TASSEL_1 + MC_3 + TAIE;           // ACLK, up-downmode

  __bis_SR_register(LPM3_bits + GIE);       // Enter LPM3
}

// Timer_A3 Interrupt Vector (TAIV) handler
#if defined(__TI_COMPILER_VERSION__) || defined(__IAR_SYSTEMS_ICC__)
#pragma vector=TIMERA1_VECTOR
__interrupt void Timer_A(void)
#elif defined(__GNUC__)
void __attribute__ ((interrupt(TIMERA1_VECTOR))) Timer_A (void)
#else
#error Compiler not supported!
#endif
{
    switch(TAIV, 10)        // Efficient switch-implementation
    {
        case  2:
            break;                        // TACCR1 not used
        case  4:
            break;                        // TACCR2 not used
        case 10:
            P1OUT ^= BIT0;                // overflow
            break;
    }
    __bic_SR_register_on_exit(LPM3_bits);
}


MSP430FR5994: I2C unable to receive from slave

$
0
0

Part Number:MSP430FR5994

I2C unable to receive from slave MSP430FR5994

The transmit part of this test code (commented out) works ok and sends data correctly to the slave.  But the receive part (shown) is not able

to receive anything from the slave.  Scope waveform shows just a short positive pulse on the i2c data line and the clock line remains solid high.

During initialization:

UCB1CTLW0 comes out 0x680.  Thus UCMST (0x800) is not set and UCTR (0x10) is not set in transmit mode.

When running receive only one byte, only get a short pulse on data line with clk staying high,

So it is not sending the slave address on receive.  ConfigI2C() is still called prior to running the Testi2c() program, but is now redundant.

 

/*******************************************************************************

         Configure USCI_B1 for I2C mode

         400khz clock

         Writes to pot in 68.8us

 

*******************************************************************************/

voidConfigI2C(void)

{

    // Configure GPIO for i2c:

    P5SEL0 |= BIT0 | BIT1;

    P5SEL1 &= ~(BIT0 | BIT1);

 

    //UCB1CTLW0 = UCSWRST;                    // put eUSCI_B in reset state

    UCB1CTLW0 |= (UCMODE_3 | 0x800 | UCSSEL__SMCLK ) ; // I2C master mode, SMCLK

    UCB1BRW = 0x12;                          // baudrate = SMCLK / 18.  With this fclk=400khz or 2.5us.  Writes in 68.8us to pot.

    //UCB1CTLW0 &= ~UCSWRST;                  // clear reset register

    UCB1IE |= UCTXIE0 | UCNACKIE;           // transmit and NACK interrupt enable

 

}

 

 

/*************************************************************************

 *              Transmit bytes to slave i2c

 *   Transmit start, slave adx, command, data, stop  to slave: (could see nack)

 ************************************************************************/

voidTransmitBytesI2c(uint8 nbytes)

{

    TxIrqFlag=1;                   //indicate now transmitting to irq

 

    UCB1CTLW0 = UCSWRST;                    // put eUSCI_B in reset state

    UCB1I2CSA = 0x04c;         // 4c configure slave adx.  MCSID bat U3=0x1a

    UCB1CTLW0 |= UCMODE_3 | UCMST | UCSSEL__SMCLK; //0x680 I2C master mode, SMCLK

    TXByteCtr = nbytes;                 // Load TX byte counter

    ByteCnt =0;                         //inc data byte counter for irq

    UCB1CTLW0 &= ~UCSWRST;                  // clear reset register

    while (UCB1CTLW0 & UCTXSTP);        // Ensure stop condition got sent

 

    UCB1IE |= UCTXIE0 | UCNACKIE;           // transmit and NACK interrupt enable

    UCB1CTLW0 |= (UCTR | UCTXSTT);        //I2C transmit start condition

}

/*************************************************************************

//Read Slave Data

//Send start, slave adx, instruction wo stop

//then send start, slave adx w read, read slave data, stop:

 *

 * start is data goes down with clock high.

**************************************************************************/

uint8 Read1byteI2c(uint8 SlaveAdx)

{

    //TransmitBytesI2c( 1);                //1 byte after slave adx = 0 command, stop

    //__delay_cycles(1000);           // wait to finish writing to slave

 

    TxIrqFlag=0;                   //indicate now receiving to irq

 

    UCB1CTLW0 = UCSWRST;                    // put eUSCI_B in reset state

    UCB1I2CSA = 0x04c;         // 4c configure slave adx.  MCSID bat U3=0x1a

    //UCB1TBCNT = 1;              //no bytes to be received

    UCB1CTLW0 &= ~UCTR ;         //clear UCTR for receive//UCB1CTLW0 = UCSWRST;                    // put eUSCI_B in reset state

    UCB1CTLW0 |= UCMODE_3 | UCMST | UCSSEL__SMCLK; // 0x680 I2C master mode, SMCLK

    UCB1CTLW0 &= ~UCSWRST;                  // clear reset register

 

    UCB1IE |=  UCRXIE0 | UCNACKIE;  // receive and NACK interrupt enable

    UCB1CTLW0 =  UCTXSTT;        //I2c  Read slave data, start condition

    while (UCB1CTLW0 & UCTXSTP);        // Ensure stop condition got sent

    __delay_cycles(1000);           // wait to finish reading the slave

 

    return RxData;

}

 

/**********************************************************************

 *          TestI2c()  Sends MSB first

 *          3.3Vccp is always on the i2c chip.

 *          This routine is normally not called.  Must be called to test.

 *          It writes to the i2c chip and increments the data written.

 *********************************************************************/

voidTestI2c(void)

{

    //SlaveFlag = 0;                          // Initialize SlaveFlag

 

    while(1)

    {

        __delay_cycles(50000);               // Delay between transmissions

        //write test data I2CData[1] to i2c pot:

        //TransmitBytesI2c( 2);                //2 bytes adx, command, stop

 

        __delay_cycles(1000);               // wait to finish writing to slave

 

        Read1byteI2c(0x4c);          //slave adx for qsm005 is 4c, mcsid u3 is 1a

      __delay_cycles(10000);           // wait to finish reading slave data

 

 

       // __bis_SR_register(LPM0_bits | GIE); // Enter LPM0 w/ interrupts                                       // Remain in LPM0 until all data                                           // is TX'd

        I2CData[1] = I2CData[1] +1 ;               // inc data for test!!!

    }

}

 

 

#if defined(__TI_COMPILER_VERSION__) || defined(__IAR_SYSTEMS_ICC__)

#pragma vector = EUSCI_B1_VECTOR

__interruptvoidUSCI_B1_ISR(void)

#elif defined(__GNUC__)

void__attribute__ ((interrupt(EUSCI_B1_VECTOR))) USCI_B1_ISR (void)

#else

#error Compiler not supported!

#endif

{

 

switch(__even_in_range(UCB1IV, USCI_I2C_UCBIT9IFG))

{

    case USCI_NONE:          break;     // Vector 0: No interrupts

    case USCI_I2C_UCALIFG:   break;     // Vector 2: ALIFG

    case USCI_I2C_UCNACKIFG:            // Vector 4: NACKIFG

        UCB1CTLW0 |= UCTXSTT;           // resend start if NACK

        break;

    case USCI_I2C_UCSTTIFG:  break;     // Vector 6: STTIFG

    case USCI_I2C_UCSTPIFG:  break;     // Vector 8: STPIFG

    case USCI_I2C_UCRXIFG3:  break;     // Vector 10: RXIFG3

    case USCI_I2C_UCTXIFG3:  break;     // Vector 12: TXIFG3

    case USCI_I2C_UCRXIFG2:             // Vector 14: RXIFG2

        ;

        break;

    case USCI_I2C_UCTXIFG2:  break;     // Vector 16: TXIFG2

    case USCI_I2C_UCRXIFG1:  break;     // Vector 18: RXIFG1

    case USCI_I2C_UCTXIFG1:  break;     // Vector 20: TXIFG1

    case USCI_I2C_UCRXIFG0:             // Vector 22: RXIFG0

        RxData = UCB1RXBUF;             // Get RX data

        break;

 

    case USCI_I2C_UCTXIFG0:             // Vector 24: TXIFG0 (txbuffer empty irq)

        if (TXByteCtr)                  // Check TX byte counter

        {

            UCB1TXBUF = I2CData[ByteCnt];  // Load TX buffer

            ByteCnt++;                  //inc the byte count

            TXByteCtr--;                // Decrement TX byte counter

        }

        else

        {

            if( TxIrqFlag==1)      //if a transmitter then send stop condition

                UCB1CTLW0 |= UCTXSTP;   // I2C stop condition

            UCB1IFG &= ~UCTXIFG;        // Clear USCI_B1 TX int flag

            __bic_SR_register_on_exit(LPM0_bits); // Exit LPM0

        }

        break;

    case USCI_I2C_UCBCNTIFG: break;     // Vector 26: BCNTIFG

    case USCI_I2C_UCCLTOIFG: break;     // Vector 28: clock low timeout

    case USCI_I2C_UCBIT9IFG: break;     // Vector 30: 9th bit

    default: break;

 

}

}

 

 

 

 

MSP430F67641A: SD24B and ADC10 Syncronization in msp430F67641A

$
0
0

Part Number:MSP430F67641A

Hello Sir,

I am sumit, i am using msp430f67641A for three phase four wire energy meter in which i am using 3 current channels of sigma delta(SD24B) and 3 voltage +1 Neutral current channels of SAR adc(ADC10,From channel number A5-A2). please tell me how to do it.

i want to use Sigma delta ISR and SAR ADC ISR for sampling , i don't want to use DMA for this purpose, i am running my board on 12MHZ clock frequency, i am taking 4096 samples in 1 sec. below is my setting .

//ADC INITILISATION

void ADC_Init()

{

// For ADC
P9SEL |= BIT1+BIT2+BIT3; 
P1SEL |= BIT0;

P1MAP0=31;
REFCTL0 = REFMSTR + REFVSEL_1 + REFON; /* Enabale Reference = 2.0V */
SD24BCTL1 &= ~SD24GRP0SC; /* SD16SC */

#if MCLK_DEF == 12
SD24BCTL0 = SD24SSEL__SMCLK /* Clock is SMCLK */
| SD24DIV2|SD24DIV0/* Divide by 16 => ADC clock: 1.048576MHz */ // SD24PDIV_1 |
| SD24REFS; /* Use internal reference */
#endif

SD_REG(SD_REG_INCTL,RI_CHANNEL) =CURRENT_CT_GAIN; 
SD_REG(SD_REG_CCTL,RI_CHANNEL) = SD24DF_1 | SD24ALGN | SD24SCS_4;
SD_REG(SD_REG_OSR,RI_CHANNEL) = 512 - 1;

SD_REG(SD_REG_INCTL,YI_CHANNEL) =  CURRENT_CT_GAIN; 
SD_REG(SD_REG_CCTL,YI_CHANNEL) = SD24DF_1 | SD24ALGN | SD24SCS_4; 
SD_REG(SD_REG_OSR,YI_CHANNEL) = 512 - 1;

SD_REG(SD_REG_INCTL,BI_CHANNEL) = CURRENT_CT_GAIN; 
SD_REG(SD_REG_CCTL,BI_CHANNEL) = SD24DF_1 | SD24ALGN | SD24SCS_4; 
SD_REG(SD_REG_OSR,BI_CHANNEL) = 512 - 1;

SD24BTRGOSR=511;
SD24BTRGPRE=0;

ADC10CTL0 =0;

 asm("NOP");

 ADC10CTL0 = ADC10SHT1 | ADC10ON | ADC10MSC;

 ADC10CTL1 = ADC10SHP | ADC10SHS_3 | ADC10DIV_2 | ADC10SSEL_3 | ADC10CONSEQ_1;

 ADC10CTL2 = ADC10RES | ADC10DF ;

ADC10MCTL0 = ADC10SREF_1 | ADC10INCH_5;

 SD24BTRGCTL |= SD24SCS__GROUP0;      /* Trigger generation group 0 +D24TRGIE */

 SD24BCTL1 |= SD24GRP0SC;            /* Start group 0 */

ADC10IFG = 0;
ADC10IE |= ADC10IE0;
ADC10CTL0 |= ADC10ENC;
SD24BIE |= SD24IE2;

}

// SAR ADC ISR

#pragma vector=ADC10_VECTOR
__interrupt void ADC10_ISR(void)
{
ADC10IFG=0;
adc_samples_channel;
adc_samples_channel=(ADC10MCTL0 & 0x000F);
switch(adc_samples_channel)
{
case 5:
asm("NOP");
break;

case 4:
V_Sample[0]=ADC10MEM0; //CH_A5 for Voltage_R
break;

case 3:
V_Sample[1]=ADC10MEM0; //CH_A4 for Voltage_Y
break;

case 2:
V_Sample[2]=ADC10MEM0; //CH_A3 for Voltage_B
break;

case 1:
I_Sample[3]=ADC10MEM0;//CH_A2 for Current_N
break;

case 0:
asm("NOP");
break;

default:
asm("NOP");
break;

}

ADC10CTL0 &= ~ADC10ENC;

ADC10CTL0 |= ADC10ENC;

}

// SD24B ISR

#pragma vector=SD24B_VECTOR
__interrupt void SD24BISR(void)
{

unsigned char i;
SD24BIFG=0;

I_Sample[0]=SD_REG(SD_REG_MEMH,RI_CHANNEL);
I_Sample[1]=SD_REG(SD_REG_MEMH,YI_CHANNEL);
I_Sample[2]=SD_REG(SD_REG_MEMH,BI_CHANNEL);

 I_Act[3]=dc_filter(&I_DC[3],I_Sample[3]);

for(i=0;i<3;i++)
{
  V_Act[i]=dc_filter(&V_DC[i],V_Sample[i]);
  I_Act[i]=dc_filter(&I_DC[i],I_Sample[i]);

}

// and the rest code--------

}

CCS/MSP432P4111: CCS/MSP432P4111

$
0
0

Part Number:MSP432P4111

Tool/software: Code Composer Studio

Hello, I am using two msp-exp432P4111 with the nrf24L01 module, everything works fine, but I would like to show on the LCD the antenna symbols "tx" or "rx", but after reading the tutorial found 

SimpleLink SDK - LCD_F Training with MSP-EXP432P4111 LaunchPad and reading the datasheet, I do not know very well how to do that. If someone can give an idea, I would appreciate it.

Other information it could useful, I programmed the whole project in pure C, except for the LCD that I used the LCD_F library which uses driverlib for some instances.

Regards in advance.

 

EVM430-AFE253S: looking for automotive compatible e-meter design

$
0
0

Part Number:EVM430-AFE253S

Hello team,

I have a requirement for e-meter (DC) which is compatible with EV/HEV application, do you have any suggestion?.

Thanks and regards,

Shai  

CCS/MSP430G2553: Determine the width of a sine wave using ADC and counter

$
0
0

Part Number:MSP430G2553

Tool/software: Code Composer Studio

I am still fairly new to CCS and the MSP430 and I'm currently trying to determine the width of an incoming analog sine wave (1 KHz) which will be offset so there is no negative component. My goal is to start a counter (using the MCLK) at the first instance of  voltage = 0 and end the counter at the second instance of voltage = 0. I know with a square wave I could easily utilize the TimerA capture mode to detect rising and falling edge of the signal and count from there. However I'm not sure how to do this with a sine wave since my counter will be interrupted by the ADC every time I check for an instance of 0. 

#include "msp430g2553.h"
#include "intrinsics.h"
int voltage=0;
int flag=1;
void main(void)
{
   WDTCTL = WDTPW  + WDTHOLD;    // stop WDT


   // ADC configuration,V+ref=3V,V-ref=0V,Channel=A0
   ADC10CTL0  = ADC10ON + ADC10IE; // Vref Vr+=3v,Vr-=VSS,
                     // S&Htime = 4 X ADCCLK,ADC10 on,ADC interrupts enabled
   ADC10CTL1  = ADC10DIV_7; // INCH =0000->A0,ADCCLK src = ADC10CLK,
                            // ADCCLK/8,Single Channel Single Conversion
   ADC10AE0   = INCH_0;     // channel A0

   ADC10CTL0 |= ENC + ADC10SC; // Start Conversion

   _BIS_SR(LPM0_bits +GIE);    // Go to LPM0,interrupts enabled

   while(1)
   {


   }

}

/***************************************************************************/
/*                 interrupt vectors for MSP430                            */
/***************************************************************************/

#pragma vector = ADC10_VECTOR
__interrupt void adc10_interrupt(void)
{
  ADC10CTL0 |= ENC + ADC10SC;  // Start Conversion again
  voltage = ADC10MEM;
  P1DIR |= BIT6;
  P1OUT &= ~BIT6;
  if(voltage>0)
  {
  voltage=voltage;
  
  }

   if(voltage==0)
    {
      P1OUT |= BIT6;
    }

  }



USB MSC Device using SPI Flash as storage media

$
0
0

Within the MSP430 USB MSP430USBDEVPACK software "ecosystem", are there any code examples that support a SPI NOR flash as the storage media to implement a USB MSC device class design?

I have seen several implementations using SD/MMC type media, but not for a "raw" SPI NOR flash chip. Does this exist within the MSP430USBDEVPACK or other TI USB support software?

FYI: I could not find a USB capable MSP430 part number from the selection list, but an example would be MSP4306638 etc...

Robert G

MSP432P401M: How to upgrade firmware to MSP432 by the other processor (Linux OS) through UART

$
0
0

Part Number:MSP432P401M

Hi, 

I have the other main processor, RK322x, on board. And it communicates to MSP432 with UART. I want to upgrade MSP432's firmware by the processor which is running Linux OS.

Especially after SMT,  MSP432 has no application firmware, How to upgrade? 

Thank you.


TIDM-VOICEBANDAUDIO: loading sound file in micro controller or external flash memory using audio loading gui

$
0
0

Part Number:TIDM-VOICEBANDAUDIO

Hello,

I'm trying to use PWM for MSP430fr5994 and boostxl audio. I went through software example and everything. I have a question, how do I load and save sound file into microcontroller or external flash memory using audio loading gui for msp430fr5994. i went through software examples but I couldn't get anything. 

MSP430G2553: MSP430G2553

$
0
0

Part Number:MSP430G2553

Hello, i am realy new on launcpad.Our university wants "MSP430G2553" launcpad. I dont wanna buy wrong one, Can anyone help me to buy?

CCS/MSP-EXP430G2: Cannot GET /apps/temperature-demo/index.html

$
0
0

Part Number:MSP-EXP430G2

Tool/software: Code Composer Studio

Hello,

I installed the latest CCS (as of 2018.06.09 :  8.0.0.00016) as well as all updates.

In Resource Explorer, while trying to open the base Temperature Monitoring Demo* I get the error message:

Cannot GET /apps/temperature-demo/index.html

Any idea how to solve this?

Thanks,

Cedric

* Under Software / MSP430Ware - v:3.80.04.05 / Development Tools / MSP-EXP430G2 / Demos / Temperature Monitoring Demo

CCS/MSP430G2553: Trying to detect the half cycle of a sine wave

$
0
0

Part Number:MSP430G2553

Tool/software: Code Composer Studio

I am still fairly new to MSP430 and CCS and I'm currently working on trying to determine how long it takes a sine wave to hit 0 twice or the half cycle of the wave. The wave is generated by a function generator at 1KHz and is offset so there is no negative component.  The ADC works fine and I can detect when the sine wave hit 0. I also have a TimerA interrupt that gets activated every 0.0001 secs at which point interuCounter is incremented and is how I keep track of time between the two 0's of the wave. However when I try to count the time in between those two instances of voltage = 0 I keep getting "difference=1" no mater what I make the frequency. With 1KHz I should expect 10. Am I implementing the timer wrong? Or is something else missing that I'm overlooking? 

#include "msp430g2553.h"
#include "intrinsics.h"
int voltage=0;
int flag1=1;
int flag2=0;
int count=0;
int preCount=0;
int difference=0;
int flag3=0;
int interuCounter;
int sawZero;
void main(void)
{
   WDTCTL = WDTPW  + WDTHOLD;    // stop WDT
   DCOCTL = 0;
   BCSCTL1 = CALBC1_1MHZ;
   DCOCTL = CALDCO_1MHZ;


   ////////////////////////////////////////////////////////
      //TimerA setup
      TA0CCR0 |= 100; //count up to 100 (1/1MHz*100 = 0.0001 sec interrupt)
      TA0CCTL0 |= CCIE;
      TA0CTL |= TASSEL_2 + MC_1;//SMCLK clock, count up mode

     // _BIS_SR(LPM0_bits + GIE); // Sleep in LPM0 with interrupts enabled

   //////////////////////////////////////////////////////////////////////////////////////////


   // ADC configuration,V+ref=3V,V-ref=0V,Channel=A0

   ADC10CTL0  = ADC10ON + ADC10IE; // Vref Vr+=3v,Vr-=VSS,
                     // S&Htime = 4 X ADCCLK,ADC10 on,ADC interrupts enabled
   ADC10CTL1  = ADC10DIV_7; // INCH =0000->A0,ADCCLK src = ADC10CLK,
                            // ADCCLK/8,Single Channel Single Conversion
   ADC10AE0   = INCH_0;     // channel A0

   ADC10CTL0 |= ENC + ADC10SC; // Start Conversion

   _BIS_SR(LPM0_bits + GIE); // Sleep in LPM0 with interrupts enabled
}

/***************************************************************************/
/*                 interrupt vectors for MSP430                            */
/***************************************************************************/

#pragma vector = ADC10_VECTOR
__interrupt void adc10_interrupt(void)
{
  ADC10CTL0 |= ENC + ADC10SC;  // Start Conversion again
  voltage = ADC10MEM;//voltage will be whatever ADC reads
  P1DIR |= BIT6;
  P1OUT &= ~BIT6;


  }



#pragma vector=TIMER0_A0_VECTOR     // Timer0 A0 interrupt service routine
   __interrupt void Timer0_A0 (void) {

   interuCounter++;//increment every 0.0001 secs

   if(flag2==1)//Enter third if statment if I see  voltage=0 again
     {
        flag3=1;
    }
    if(voltage==0 && flag1==1)
     {
        preCount =interuCounter; //count when I first saw voltage=0
        flag1=0; //Don't enter this statement again unless I've already seen 0 twice
        flag2=1;//Enter third if statment if I see voltage=0 again
     }
    if(voltage==0 && flag3==1)
        {

           flag1=1;//RESET
           flag2=0;//RESET
           flag3=0;//RESET
           count=interuCounter;//count at second instance of voltage=0
           difference = count-preCount; //Difference between first instance an second instance of 0
           P1OUT |= BIT6;


        }


}

 

CCS/MSP430FR2433: question about CS of MSP430fr2433

$
0
0

Part Number:MSP430FR2433

Tool/software: Code Composer Studio

Hello Everyone !!!

I'm new user of MSP microcontroller and I have questions about the System Oscilator. I'm using  MSP430FR2433

I have the follow setup 

__bis_SR_register(SCG0); // disable FLL
CSCTL3 |= SELREF__REFOCLK; // Set REFO as FLL reference source
CSCTL0 = 0; // clear DCO and MOD registers
CSCTL1 &= ~(DCORSEL_7); // Clear DCO frequency select bits first

CSCTL1 |= DCORSEL_3; // Set DCO = 8MHz
CSCTL2 = FLLD_0 + 243;

__delay_cycles(3);
__bic_SR_register(SCG0); // enable FLL
while(CSCTL7 & (FLLUNLOCK0 | FLLUNLOCK1)); 

When I use this equation: FDCOCLKDIV = (FLLN + 1) × (fFLLREFCLK ÷ n),  e.g REFO = 32.768 KHz

The result is  7995392 MHz   ... Why ? I need to use external oscilator 32KHz to have correct frequency ? 

I want to have exactly 8 Mhz using DCO !!! Is it possible using DCO ?

Viewing all 22212 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>