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

CCS/CODECOMPOSER: How to read high memory from CCS plugin

$
0
0

Part Number:CODECOMPOSER

Tool/software: Code Composer Studio

Code Composer Studio version:  Version: 8.3.0.00009

Host OS: Windows 10 64 bit

Processor: MSP430F5659
Processor options: mspx, large data and code model

Debugger: MSP-EXP430F5529LP and MSP-EXP430FR5994

I'm trying to write plugin for CCS which needs to read high memory (address 0x10000 or higher).

I'm able to read low memory with this snippet:

long startAddress = 0x8000;

long toRead = 0x10;

IMemoryBlockRetrieval memoryblockretr = (IMemoryBlockRetrieval)context.getAdapter(IMemoryBlockRetrieval.class);
IMemoryBlockExtension memoryblock = ((IMemoryBlockRetrievalExtension)memoryblockretr).getExtendedMemoryBlock(Long.toString(startAddress), (Object)context);
MemoryByte[] bytes = memoryblock.getBytesFromAddress(memoryblock.getBigBaseAddress(), toRead);

It works for both RAM and FLASH memory in MSP430X.

However, when I change startAddress to 0x10000, 0x18000, or 0xf0000 it reads memory from 0x0000, 0x8000, or 0x0000 respectively. It looks like it lost 4 most significant bits of address.

Reading 0x20 bytes from 0xfff0 works correctly: I'm getting bytes from 0xfff0 to 0x10010.

How to read memory from 0x10000 or higher?

Can this be a bug connected with ?


MSP430F5438A: Long delay after SPI byte was shifted out

$
0
0

Part Number:MSP430F5438A

Hi,

I run the MSP@1MHz. SPI is in master mode. Fo some reason I measure about 50uS delay after the byte was shifted out until CS is set back to 1 in the spi_tx_byte() function.

Here is the function and IRQ code.

Do you have an idea what causes the delay?

Peter

// sending one byte via SPI
inline void spi_tx_byte(uint8_t data){

    _txLen=0;

    while (!(UCA0IFG&UCTXIFG));               // USCI_A0 TX buffer ready?
    dog_set_cs(0);
    UCA0TXBUF = data;                         // Transmit one character
    __bis_SR_register(LPM0_bits + GIE);  // Enter low power mode once
    __no_operation();
    dog_set_cs(1);
}


#pragma vector=USCI_A0_VECTOR
__interrupt void USCI_A0_ISR(void)
{
  switch(__even_in_range(UCA0IV,4))
  {
    case 0: break;                          // Vector 0 - no interrupt
    case 2:{                                 // Vector 2 - RXIFG
        while (!(UCA0IFG&UCTXIFG));             // USCI_A0 TX buffer ready?
        if(_txLen!=0){
            _pTx++;
            UCA0TXBUF = *_pTx;;
            _txLen--;
        }else{
            // wake up main loop
            __bic_SR_register_on_exit(LPM0_bits);
        }
      break;
    }
    case 4:                                 // Vector 4 - TXIFG
    break;


    default: break;
  }
}

Does MSPFET have memory (RAM or flash), and if so, how much?

$
0
0

I need to know if the MSPFET has memory (RAM or flash), and if so, how much. I don't need to know about the MSP430, just the flash emulation tool (MSPFET). The form does not allow MSPFET as a part number.

Compiler/MSP430FR6989: Flashing code onto device using MSPFlasher_1.3.18

$
0
0

Part Number:MSP430FR6989

Tool/software: TI C/C++ Compiler

I am experimenting with the FR6989 and trying to flash ('upload') the example blink.c from msp430-gcc. To get a feel for the program I tried to read the launchpad demo code (temperature/stopwatch) into the computer through the documentation example command but it was unable to set vcc

./MSP430Flasher -n MSP430FR6989 -r [output.txt,MAIN]
* Unable to access log file. Creating folder...done
* -----/|-------------------------------------------------------------------- *
* / |__ *
* /_ / MSP Flasher v1.3.18 *
* | / *
* -----|/-------------------------------------------------------------------- *
*
* Evaluating triggers...done
* Checking for available FET debuggers: 
* Found USB FET @ ttyACM0 <- Selected
* Initializing interface @ ttyACM0...done
* Checking firmware compatibility: 
* The firmware of your FET is outdated.
- Would you like to update it? (Y/N): n
* Warning: FW mismatch! Correct functionality not guaranteed!
* Reading FW version...done
* Setting VCC to 3000 mV...
# Exit: 44
# ERROR: Could not set device Vcc
* Powering down...done
* Disconnecting from device...
* ----------------------------------------------------------------------------
* ERROR on close: Could not set device Vcc
* ----------------------------------------------------------------------------
*/

So I then tried to update the firmware which failed and now I'm left without the example demo

./MSP430Flasher -n MSP430FR6989 -r [output.txt,MAIN]
* -----/|-------------------------------------------------------------------- *
*     / |__                                                                   *
*    /_   /   MSP Flasher v1.3.18                                             *
*      | /                                                                    *
* -----|/-------------------------------------------------------------------- *
*
* Evaluating triggers...done
* Checking for available FET debuggers: 
* Found USB FET @ ttyACM0 <- Selected
* Initializing interface @ ttyACM0...done
* Checking firmware compatibility: 
* The firmware of your FET is outdated.
- Would you like to update it? (Y/N): Y

*********************************************************
*                                                        
*  Initializing Update Bootloader.                       
*  Programming new firmware:                             
*  |||||||||||||||||||||||||||||||||||||||||||||||||| 100%* Update failed. (R)etry/(C)ancel? c
# Exit: 49
# ERROR: MSP-FET / eZ-FET core(communication layer) update failed
* * ----------------------------------------------------------------------------
* Driver      : closed (No error)
* ----------------------------------------------------------------------------
*/

How do I flash new code onto the device since it's unable to set VCC?

RTOS/MSP432P401R: FatFS with EEPROM?

$
0
0

Part Number:MSP432P401R

Tool/software: TI-RTOS

Dear,

I just read

http://dev.ti.com/tirex/content/simplelink_cc13x0_sdk_1_40_00_10/docs/simplelink_mcu_sdk/Users_Guide.html#making-choices-for-your-application

in the section FatFS, it seems RTOS provides drivers for using this filesystem with SD cards (SDSPI) and USB devices.

However, I was wondering if there is any issue in trying to use FatFS with a SPI 1Gbit flash memory.

  1. Is the implementation of such driver a realistic effort? I plan to use MSP432. Memory would be not accessed very often.
  2. Are there similar examples and/or documentation related to this case you would recommend me? I will look into this thread meanwhile:

Please let me know and have a beautiful weekend.

MSP430F5335: Problem with nested interrupts and LPM

$
0
0

Part Number:MSP430F5335

I am observing an issue with nested interrupts. I know I should avoid using nested interrupts but believe me, in this case there was no other choice.

This is the scenario:

- MSP is in Low Power Mode 3 (LPM3).

- RTC interrupt occurs.

- Inside the RTC's ISR, I set GIE to enable nesting.

- TA0 (or others) interrupts before returning from RTC's ISR (nesting).

- Inside the TA0 I change the Status Register (SR) bits to exit LPM (using __bic_SR_register_on_exit).

- The MSP does not respond anymore.

Note: If I don't try exiting LPM from the nested interrupt, the MSP behaves as expected.

In the following thread, Jens-Michael Gross, mentioned that "the nested interrupt cannot exit LPM".

https://e2e.ti.com/support/microcontrollers/msp430/f/166/t/349661?Nested-interrupts-and-jump-table 

I understand the SR and PC are saved in the stack twice. Then, at the end of the nested interrupt ISR, the latest SR saved in the stack is modified (to exit LPM) and retrieved, then the PC will retrieved an instruction from the RTC's ISR and will continue executing the RTC's ISR. Then, at the end of the RTC's ISR, the SR will be retrieved again form the stack with the values saved before entering the RTC's ISR. For that reason, the MSP will not go out form LPM in that moment.

But, what I don't understand is why the MSP doesn't wake up at all, later when another interrupt occurs and there is no nesting enabled.

I would really appreciate any inputs on this matter.

Thanks in advance.

MSP430F2012: User Guide for MSP430F2012

$
0
0

Part Number:MSP430F2012

Hello ....,
I would like to develop an I2C slave program suitable for a MSP430F2012.
I have a User Guide SLAU144i Revised January 2012. There is a newer User Guide Revised July 2013. This document is different in relation to I2C-Mode (Chapter 14 January 2012 compared with Chapter 17 July 2013). The Software-Examples also are not suitable for chapter "User Guide Revison July 2013, I2C-Mode". Is there a newer Release "MSP430F2012" with a newer I2C-Modul?
Regards Jurgen

CCS/MSP432P401R: CCS v8.3.0 Problems with Serial Terminal and CR

$
0
0

Part Number:MSP432P401R

Tool/software: Code Composer Studio

Hello,

I just updated CCS from v7.4.0 to v8.3.0 in a 64 bit Linux VM for my microcontroller classes next summer semester.
I am using the MSP432 Launchpads. When connecting a serial Terminal (View->Terminal) to /dev/ttyACM0, I
noticed that no carriage returns (CR) are processed by the Terminal. Using a external serial monitor program
(gtkterm) the output is shown correctly. So the boards DO send the CR via the serial interface, but the Terminal
view does not process them correctly. Without CR, the output is quite garbled and not readable.

Could this be verified and fixed? My students are using the Terminal quite a lot for outputting text/debug messages
during their practial exercises.

Best regards, Andreas


MSP430G2553: Problem with non-volatile flash memory and mspflash.h library

$
0
0

Part Number:MSP430G2553

Hello. I know, that this should better be posted on 43oh.com forum, but I got no answer from there.


I have wrote a simple Energia program for digital potentiometer control with incremental rotary encoder. They are connected to MSP430G2553 launchpad.

I want to save variable "counter" (it is an integer number from 0-255) in non-volatile memory using mspflash.h library in case of reset or power interrupt. But it doesn't saves it.
I am allmost sure there is something wrong with initialization of variables or pointers inside my code. Can anyone help? Any improvements in code?

My code:

#include <SPI.h>
#include "MspFlash.h"

#define outputA P2_1
#define outputB P2_2

#define flash SEGMENT_D

 int aState;
 int aLastState;  

 const int slaveSelectPin = SS;
 const int shutDownPin = P1_4;

int pos=0;
int counter=0;
int p=0;

void setup() {

    pinMode (outputA,INPUT_PULLUP);
    pinMode (outputB,INPUT_PULLUP);
    aLastState = digitalRead(outputA);
 
  pinMode (slaveSelectPin, OUTPUT);
  pinMode (shutDownPin, OUTPUT);
    SPI.begin();
  digitalWrite(shutDownPin, HIGH);
  digitalPotWrite(1, 0);
}

void loop() {
 
Flash.read(flash+(pos * sizeof(int)), (unsigned char*)&p, sizeof(int));

      aState = digitalRead(outputA);
   if (aState != aLastState){     
     if (digitalRead(outputB) != aState) {
        counter=++counter;
     } else {
        counter=--counter;
     }
   }
   if (counter <= 255) {
   if (counter < 0) {
   digitalPotWrite(1, 0);
   counter = 0;
   Flash.erase(flash);
   Flash.write(flash+(pos * sizeof(int)), (unsigned char*)&counter, sizeof(int));
   }
   else {
   digitalPotWrite(1, counter);
   Flash.erase(flash);
   Flash.write(flash+(pos * sizeof(int)), (unsigned char*)&counter, sizeof(int));
   }
   }
    if (counter > 255) {    
   digitalPotWrite(1, 255);
   counter = 255;
   Flash.erase(flash);
   Flash.write(flash+(pos * sizeof(int)), (unsigned char*)&counter, sizeof(int));  
   }
       aLastState = aState;
}
int digitalPotWrite(int address, int value) {
  digitalWrite(slaveSelectPin,LOW);
  SPI.transfer(address);
  SPI.transfer(value);
  digitalWrite(slaveSelectPin,HIGH);
}

 

Thank you in advance,

Superpanky

MSP430FR2522: MSP430FR2522 BOOSTXL-CAPKEYPAD Evaluation Board Enquiry

$
0
0

Part Number:MSP430FR2522

Hi,

I am looking at MSP430FR2522IRHL BOOSTXL-CAPKEYPAD Evaluation board.

Can you share with me detailed information on this EVM PCB design (such as PWB layer stack, ground hatching trace width & gap, signal & ground gap, overlay max thickness etc)?

Would like to use this EVM layout as the benchmark for PCB design.

Thanks,

Phil

MSP430FR2433: Backup memory documentation needs improvement

$
0
0

Part Number:MSP430FR2433

Here I offer my experience trying to understand the documentation for backup memory.

SLAU445h (family user guide) says  "Configurable from 32 bytes to 256 bytes".  It should say something like "each device in the family has a different number of backup memory locations."  IMO there is no end-user action to "configure" the memory.  

SLAU445h also documents only two registers, BAKMEM0 and BAKMEM1.  IMO these are just examples.  Each device will have a different number of registers.  The registers do not "control" anything, they are just memory locations that can be read and written.  The document could just say that, and use one example register e.g. "BAKMEMx"

SLASE59B (datasheet for MSP430FR2433) says "This device provides up to 32 bytes that are retained during LPM3.5." IMO it should say "provides exactly 32 bytes".  It could also say "in 16 named word locations."

Also, as discussed in the linked thread, it is not clear why one would want to use backup memory instead of FRAM.  The documentation could say that one reason is:  to dynamically write FRAM, you must first disable VMA NMI upon writing to FRAM.  That is, you can always write to backup memory, but a write to FRAM will trigger a VMA NMI unless that has been disabled.

Also, the linked thread confuses the issue whether FRAM is unpowered with whether FRAM contents are lost during LPM4.5.   In that thread, a TI employee says "The difference between FRAM and backup memory is that the latter is retained during LPM3.5."  Table 6-1 is cited, and that table shows that FRAM is "off" during LPM3.5 (and other modes) but that only means FRAM is unpowered, not that FRAM contents are lost through LPM3.5.  

The reason I was looking at the documentation, I was exploring whether I needed to disable backup memory to enter LPM4.5, using some sort of control register.  The documentation could say "power to backup memory is automatic, determined by the LPM mode."

I could be wrong.  To summarize, I think a paragraph or two of explanation in the family user's guide would help.

RTOS/MSP432E401Y: System_printf for data sending on uart

$
0
0

Part Number:MSP432E401Y

Tool/software: TI-RTOS

Hi..

Can any one help me in using the "System_printf" function. I am using "Nvsinternal" example, in that i want to output the base address and sector size values on to the uart.

Currently i am using UART4.

I have gone through some of the forum posts which mainly suggesting that to add the header file 

"#include <xdc/runtime/System.h>" in main file

and the below initialisation in  .cfg file.

var System = xdc.useModule("xdc.runtime.System");

var SysMin = xdc.useModule("xdc.runtime.SysMin");

SysMin.bufSize = 0;

SysMin.flushAtExit = false;

System.SupportProxy = SysMin; /* not really necessary since SysMin is the default */

But here in the example code there is no such .cfg file.

I have used that system.h header in the nvsinternal.c file and directly used System_printf function for display. however there is no output on the console.

So please explain me - how to use this "System_printf" function for sending the data out over UART4. 

Thank you

Regards

Kalyan.

CCS/MSP430FR2355: About boot.c

$
0
0

Part Number:MSP430FR2355

Tool/software: Code Composer Studio

Hi,

  I'm really new to the CCS. I'm now using the MSP430FR2355.

  When I upload the code and get into the debug mode. I set some breakpoint in the TimerB interrupt.

  But when I click the start button in the debug mode, the code always stop somewhere before the breakpoint, then next time I click the start button, the code stops at the breakpoint.

  And sometime after I click the start button, the CCS seems to stop and show the "boot.c" file. And the pointer point to the below.

CSTART_DECL _c_int00_noargs_mpu(void)
{
_c_int00_template(0, 1, 1);   // where pointer point to
}

  I'm not sure what happens. If anyone can help, I'm so grateful.

Below is mine timer code and interrupt

-----------------------------------------------------------

tb(2000);

__bis_SR_register(LPM3_bits | GIE); // Enter LPM3 w/ interrupt
}

#pragma vector = TIMER0_B0_VECTOR
__interrupt void Timer_B (void)
{
ir++;
if (t<50){
sw(RH_RF95_REG_01_OP_MODE, RH_RF95_MODE_STDBY);  // SW IS FUNTION TO WRITE REGISTER IN RFM95
sw(0x0D, 0); // Pointer point to 0
sw(RH_RF95_REG_00_FIFO, t);
sw(0x01, RH_RF95_MODE_TX);
sw(RH_RF95_REG_01_OP_MODE, RH_RF95_MODE_SLEEP | RH_RF95_LONG_RANGE_MODE);
t++;
}
__no_operation();    // WHERE I PUT BREAKPOINT

}
// ----------------------------------------------------------------------------------------------------
void tb (int tm)
{
TB0CTL = TBSSEL__ACLK | MC__UP;
TB0CCR0 = tm;
TB0CCTL0 |= CCIE; // TACCR0 interrupt enabled
}

CCS/MSP430FR5994: Write a breakpoint in assembly

$
0
0

Part Number:MSP430FR5994

Tool/software: Code Composer Studio

In Assembly language, if I wanted to put something in my code that would trigger the breakpoint mechanism in CCS, what would I write?

I am using the GNU assembler and can't seem to get the "ordinary" breakpoint to work.  I remember when I encountered this problem on an x86 processor I could trip an interrupt and break.  I was hoping I could do something similar in GNU assembly.

Compiler/EVM430-F6736: Compiler error in IAR while working with single phase energy meter using EVM430f6736.

$
0
0

Part Number:EVM430-F6736

Tool/software: TI C/C++ Compiler

I want to implement the energy meter measurement using EVM430-f6736.

But I'm using the IAR embedded Workbench version 7.12.1. I loaded the project emeter-toolkit-6722.ewp (slaa517) and then I rebuild this code. It shows a lot of compiler error for each file present in this emeter-toolkit-6733.

The error will be like this : fatal errror [pe035] #error directive: compiler not recognized.

How can I resolved this one?


MSP430F449: How to understand "cumulative program time" on Flash program.

$
0
0

Part Number:MSP430F449

Hi TI guys,

I'm now working on a OTA upgrade project use MSP430F449. and confused by the notion:cumulative program time and cumulative .mass erase time. Need your help. :)

If chose the fastest  fFTG= 476KHz ,that means Tftg= 1/476KHz=0.0021ms

Program a byte need 35 fFTG, about 0.0021x35=0.0735ms

If  cumulative program time is 10ms , that makes 10ms/0.0735=136 byte.

Does it mean the input parameter Lenth can't larger than 136?

Besides, how to understand cumulative .mass erase time?  Iam puzzed with NOTES 2 .

B.R

Seafesse

void MSPBoot_MI_WriteBytes(uint16_t Flash_adr, uint08_t* Sram_adr,
                            uint08_t Lenth)
{ 
    uint16_t i;
   // fFTG = 476KHz (Max)
    FCTL2 = FWKEY + FSSEL_2 + FN0 + FN1 + FN2;
    FCTL3 = FWKEY;
    FCTL1 = FWKEY+ WRT;    
    for(i=0;i<Lenth;i++)
    {
        while(0 ==(FCTL3 & WAIT) );
        *( (uint08_t*)Flash_adr ) = *Sram_adr;  
        Flash_adr++;
        Sram_adr++;
    }
    FCTL1 = FWKEY;  
    while( BUSY & FCTL3);
    FCTL3 = FWKEY + LOCK;
}

CCS/MSP430G2553: BREAKPOINT -> PWM STOPP

$
0
0

Part Number:MSP430G2553

Tool/software: Code Composer Studio

Hello,

Launchpad MSP-EXP430G2 -> MSP430G2553.

PWM on P2.2 and P1.6.

When the program runs on a BREAKPIONT, the PWM stops.

Can one adjust that somewhere, that the PWM keeps running, as with the
Picolo (TMS320F28069 ... ) series?

Or at least that the PWM outputs when reaching a BREAKPOINT
to assume a predeterminable state?


MSP432P401R: ADC multi channel readings are inaccurate.

$
0
0

Part Number:MSP432P401R

Hello, I'm trying to program the ADC in the msp432 launchpad (red) that converts 3 channels indefinitely. Channel 1 will range between 3 to 3.3 V. Channel 2 will range between 0 to 3.3V and the third channel will vary between 0 and 0.5 V. Every time I read the result after the sequence ends, the results are all over the place for all the channels. I configured the multi channel ADC to use a timer source with SMCLK being at 12 MHz. The period on the timer is set at 12000 and the capture compare is also at 12000. Ideally, this would mean a 12 KHz sampling rate? What I want to accomplish is obtain accurate readings for all 3 channels and then transmit them to another device every 0.5 seconds and repeat this process indefinitely.

#include <ti/devices/msp432p4xx/driverlib/driverlib.h>

/* Standard Includes */
#include <string.h>
#include <stdint.h>
#include <stdbool.h>
#include "ClockSys.h"

#define RESOLUTION 16384
#define Vref 3.3
#define SAMPLE_LENGTH 100

// Global variables
static uint16_t ADC_result_buffer[3];
static uint32_t voltage_buffer;
static uint32_t curr1_buffer;
static uint32_t curr2_buffer;
bool transmit;
static int i;

const Timer_A_UpModeConfig upModeConfig = {
TIMER_A_CLOCKSOURCE_SMCLK,            // SMCLK Clock Source
TIMER_A_CLOCKSOURCE_DIVIDER_1,       // SMCLK/1 = 12 MHz
12000,                  //  12 KHz sampling rate (1ms period)
TIMER_A_TAIE_INTERRUPT_DISABLE,      // Disable Timer ISR
TIMER_A_CCIE_CCR0_INTERRUPT_DISABLE, // Disable CCR0
TIMER_A_DO_CLEAR                     // Clear Counter
};

// Timer_A Compare Configuration Parameter
const Timer_A_CompareModeConfig compareConfig = {
TIMER_A_CAPTURECOMPARE_REGISTER_1,          // Use CCR1
TIMER_A_CAPTURECOMPARE_INTERRUPT_DISABLE,   // Disable CCR interrupt
TIMER_A_OUTPUTMODE_SET_RESET,               // Toggle output but
12000          // 1ms Period
};

/** MAIN **/
void main(void) {

    /* Stop Watchdog  */
    WDT_A_clearTimer();
    WDT_A_holdTimer();

/*  DCO = MCLK = 48 MHz
 *  HSMCLK to 24 MHz
 *  Sets SMCLK to 12 MHz */
    ClockSys_SetMaxFreq();


    /* Enabling the FPU for floating point operation */
    FPU_enableModule();
    FPU_enableLazyStacking();

    /* Initialize ADC buffers to 0 */
    memset(ADC_result_buffer, 0x00, 3 * sizeof(uint16_t));
    voltage_buffer = 0;
    curr1_buffer = 0;
    curr2_buffer = 0;
    i = 0;

    /* Initialize ADC to measure Voltage and currents */
    ADC14_setResolution(ADC_14BIT);

    /* Turn on ADC module */
    ADC14_enableModule();
    /* Configure ADC to use master clock, no prescalers, and no routing */
    ADC14_initModule(ADC_CLOCKSOURCE_SMCLK, ADC_PREDIVIDER_1, ADC_DIVIDER_1, ADC_NOROUTE);

    /* Configuring GPIOs for Analog In */
    GPIO_setAsPeripheralModuleFunctionInputPin(GPIO_PORT_P4,
                                                   GPIO_PIN4 | GPIO_PIN5 | GPIO_PIN7,
                                                   GPIO_TERTIARY_MODULE_FUNCTION);

    /* Configuring ADC Memory [0..2] with repeat mode and internal 3.3V
     * reference */
    ADC14_configureMultiSequenceMode(ADC_MEM0, ADC_MEM2, true);
    ADC14_configureConversionMemory(ADC_MEM0, // A6 = P4.7
                                    ADC_VREFPOS_AVCC_VREFNEG_VSS,
                                    ADC_INPUT_A6, ADC_NONDIFFERENTIAL_INPUTS);
    ADC14_configureConversionMemory(ADC_MEM1, // A8 = P4.5
                                    ADC_VREFPOS_AVCC_VREFNEG_VSS,
                                    ADC_INPUT_A8, ADC_NONDIFFERENTIAL_INPUTS);
    ADC14_configureConversionMemory(ADC_MEM2, // A9 = P4.4
                                    ADC_VREFPOS_AVCC_VREFNEG_VSS,
                                    ADC_INPUT_A9, ADC_NONDIFFERENTIAL_INPUTS);

    /* Configuring Timer_A in continuous mode and sourced from SMCLK */
    Timer_A_configureUpMode(TIMER_A0_BASE, &upModeConfig);

    /* Configuring Timer_A0 in CCR1 to trigger at 12000 (1 ms) */
    Timer_A_initCompare(TIMER_A0_BASE, &compareConfig);

    /* Configuring the sample trigger to be sourced from Timer_A0  and setting it
     * to automatic iteration after it is triggered*/
    ADC14_setSampleHoldTrigger(ADC_TRIGGER_SOURCE1, false);
    //ADC14_setSampleHoldTime(ADC_PULSE_WIDTH_192, ADC_PULSE_WIDTH_192);

    /* Enabling the interrupt when a conversion on channel 2 (end of sequence)
     * is complete and enabling conversions */
    ADC14_enableInterrupt(ADC_INT2);

    ADC14_enableSampleTimer(ADC_AUTOMATIC_ITERATION);

    ADC14_enableConversion();

    /* Enable ADC Interrupt */
    Interrupt_enableInterrupt(INT_ADC14);
    Interrupt_enableMaster();

    /* Starting the Timer */
    Timer_A_startCounter(TIMER_A0_BASE, TIMER_A_UP_MODE);

    while(1) {
        if (transmit) {
            // Doing something here that can't be interrupted
            transmit = false;
            ADC14_enableConversion();
            Interrupt_enableInterrupt(INT_ADC14);
        }
    }
}


void ADC14_IRQHandler(void) {
    uint64_t status;

    status = ADC14_getEnabledInterruptStatus();
    ADC14_clearInterruptFlag(status);

    if(status & ADC_INT2) {

        ADC14_getMultiSequenceResult(ADC_result_buffer);
        ++i;
        if (i == SAMPLE_LENGTH) {
            Interrupt_disableInterrupt(INT_ADC14);
            ADC14_disableConversion();
            i = 0;
            voltage_buffer /= SAMPLE_LENGTH;
            curr1_buffer /= SAMPLE_LENGTH;
            curr2_buffer /= SAMPLE_LENGTH;
            transmit = true;
            meter_info.voltage = voltage_buffer;
            meter_info.curr1 = curr1_buffer;
            meter_info.curr2 = curr2_buffer;
            meter_info.meter_requesting = true;
            voltage_buffer = 0;
            curr1_buffer = 0;
            curr2_buffer = 0;
        }
        voltage_buffer += ADC_result_buffer[0];
        curr1_buffer += ADC_result_buffer[1];
        curr2_buffer += ADC_result_buffer[2];


    }
}

CCS/MSP430F2619: Too much current draw while in LPM3

$
0
0

Part Number:MSP430F2619

Tool/software: Code Composer Studio

I am currently programming the MSP430F2619 chip with the 64 pin DEV board. When I run a the simple ta1 example code and enter LPM3 I see 1 uA current draw in low power mode which is exactly what I expect. However now I am trying to use the ADC12 with a timer interrupt.I am measuring the on board temp sensor and measuring P6.0 as well. It seems no matter what I turn off after getting the ADC12 measurements I am still drawing 1.3 mA when I enter LPM3. I have set break points everywhere and it appears the code is working correctly but I can't seem to get ~1uA in LPM3 while using the ADC12.

/* --COPYRIGHT--,BSD_EX
 * Copyright (c) 2012, Texas Instruments Incorporated
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *
 * *  Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 *
 * *  Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 *
 * *  Neither the name of Texas Instruments Incorporated nor the names of
 *    its contributors may be used to endorse or promote products derived
 *    from this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 *
 *******************************************************************************
 *
 *                       MSP430 CODE EXAMPLE DISCLAIMER
 *
 * MSP430 code examples are self-contained low-level programs that typically
 * demonstrate a single peripheral function or device feature in a highly
 * concise manner. For this the code may rely on the device's power-on default
 * register values and settings such as the clock configuration and care must
 * be taken when combining code from several examples to avoid potential side
 * effects. Also see www.ti.com/grace for a GUI- and www.ti.com/msp430ware
 * for an API functional library-approach to peripheral configuration.
 *
 * --/COPYRIGHT--*/
//*****************************************************************************
//  MSP430x26x Demo - ADC12, Sample A10 Temp, Set P1.0 if Temp ++ ~2C
//
//  Description: Use ADC12 and the integrated temperature sensor to detect
//  temperature gradients. The temperature sensor output voltage is sampled
//  ~ every 60ms and compared with the defined delta values using an ISR.
//  (ADC12OSC/256)/ determines sample time which needs to be greater than
//  30us for temperature sensor.
//  ADC12 is operated in repeat-single channel mode with the sample and
//  convert trigger sourced from Timer_A CCR1. The ADC12MEM0_IFG at the end
//  of each converstion will trigger an ISR.
//  ACLK = n/a, MCLK = SMCLK = default DCO ~ 1.045M, ADC12CLK = ADC12OSC
//
//           MSP430F261x/241x
//            -----------------
//        /|\|              XIN|-
//         | |                 |
//         --|RST          XOUT|-
//           |                 |
//           |A10          P1.0|-->LED
//
//  B. Nisarga
//  Texas Instruments Inc.
//  September 2007
//  Built with CCE Version: 3.2.0 and IAR Embedded Workbench Version: 3.42A
//******************************************************************************

#include <msp430.h>

#define ADCDeltaOn   12                     // ~2 Deg C delta

//static unsigned int FirstADCVal;            // holds 1st ADC result
int in_value1=0, in_value2=0;
int main(void)
{
  WDTCTL = WDTPW + WDTHOLD;                 // Stop watchdog

  /////////TIMER//////////////////////////////////
    TACCTL1 = OUTMOD_4;                       // Toggle on EQU1 (TAR = 0)
    TACTL = TASSEL_1 + MC_1 + ID_0; // ACLK, divider of 1, up mode
    TACCR0 = 65000;                  // 8192 ACLK periods = 0.25 seconds
    TACCTL0 = CCIE; // Enable interrupt on Timer A2
///////////TURN ON CRYSTAL/////////////////////////
      BCSCTL1 &=  ~XTS;
      BCSCTL3 |= XT2S_0 + LFXT1S_0 + XCAP_3;


          do

          {
              IFG1 &= ~OFIFG;
              __delay_cycles(100);
          }
          while(IFG1 & OFIFG);

          BCSCTL2 |= SELM_3;
          BCSCTL2 |= DIVM_0;


  ///////ADC/////////////////////////////////
  ADC12CTL1 = SHS_0 + SHP + CONSEQ_3;       // TA trig., rpt conv.
  ADC12MCTL0 = SREF_1 + INCH_0;
  ADC12MCTL1 = SREF_1 + INCH_10 + EOS;// Channel A10, Vref+
  ADC12IE = 0x01;                           // Enable ADC12IFG.0

  ADC12CTL0 = SHT0_8 + REF2_5V + REFON + ADC12ON + ENC + MSC; // Config ADC12

  //HANDLE PINS/////////////////////////

    P1DIR = 0xFF;//Initialize ports
    P1OUT = 0x00;
    P2DIR = 0xFF;//Initialize ports
    P2OUT = 0x00;
    P3DIR = 0xFF;//Initialize ports
    P3OUT = 0x00;
    P4DIR = 0xFF;//Initialize ports
    P4OUT = 0x00;
    P5DIR = 0xFF;//Initialize ports
    P5OUT = 0x00;
    P6DIR = 0xFF;//Initialize ports
    P6OUT = 0x00;
    P7DIR = 0xFF;//Initialize ports
    P7OUT = 0x00;
    P8DIR = 0xFF;//Initialize ports
    P8OUT = 0x00;
    PAOUT = 0;
    PADIR = 0xFFFF;




    while (1)
    {
        ADC12CTL0 &= ~ADC12ON; //ADC OFF
        P6DIR = 0xFF;//Initialize ports
        P6OUT = 0x00;
        ADC12IE = 0x00;
        ADC12CTL0 &= ~REF2_5V; //Reference voltage off
        __bis_SR_register(LPM3_bits + GIE);       // Enter LPM3 w/ interrupt

    }
}


// Timer A0 interrupt service routine
#if defined(__TI_COMPILER_VERSION__) || defined(__IAR_SYSTEMS_ICC__)
#pragma vector=TIMERA0_VECTOR
__interrupt void Timer_A (void)
#elif defined(__GNUC__)
void __attribute__ ((interrupt(TIMERA0_VECTOR))) Timer_A (void)
#else
#error Compiler not supported!
#endif
{

    P6SEL |= 0x01;                            // P6.0-ADC option select
    P6SEL |= BIT0;                            //Connect pin to A0 input
    ADC12CTL0 |= ADC12ON; //ADC ON
    ADC12IE = 0x01; //ADC12 interrupt enabled
    ADC12CTL0 |= REF2_5V; //Reference votlage on
    ADC12CTL0 |= ADC12SC; //Software controlled start sample and hold
    __bic_SR_register(LPM3_bits + GIE ); ///Exit LPM3, go back to main

}





//////////////////////ADC Interrupt///////////////////////
///////Interrupt happens when sample and hold conversion is done/////////////////
#if defined(__TI_COMPILER_VERSION__) || defined(__IAR_SYSTEMS_ICC__)
#pragma vector=ADC12_VECTOR
__interrupt void ADC12ISR (void)
#elif defined(__GNUC__)
void __attribute__ ((interrupt(ADC12_VECTOR))) ADC12ISR (void)
#else
#error Compiler not supported!
#endif
{

    in_value1= ADC12MEM0; //P6.0
    in_value2= ADC12MEM1; //On board temperature sensor

    __bic_SR_register_on_exit(LPM3_bits + GIE); // Exit active CPU ///Exit LPM3, go back to main


}

MSP430FR2000: 25 for 25, SPI FLASH solution. What SPI host device/program was used to test?

Viewing all 21954 articles
Browse latest View live


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