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

MSP430F5528: FIlesystem causing issue while copying or deleting the data

$
0
0

Part Number:MSP430F5528

Hello,

I am using some memory of the flash as a filesystem and storing some data in file system to use it in run time. Following are the cases which are erasing or corrupting the flashed firmware and I need to flash the firmware again.

  1. when I delete the file from the filesystem (happen sometimes).
  2. when I copy the more data in filesystem then its size allocated (happen always).

Please provide solution to prevent this situation for above cases.

Regards,

Rohit


CCS/MSP430FR5994: Error Setting Multiple Timer Frequencies

$
0
0

Part Number:MSP430FR5994

Tool/software: Code Composer Studio

I am trying to generate multiple frequencies from timer interrupts (to flash LEDs at different rates, etc.) using Multiple Time Bases similar to the two links below.

www.ti.com/.../slaa513a.pdf
e2e.ti.com/.../1165370

However, when I try to set "TA0CCTL3" and "TA0CCR3" (and 4/5/6, not shown here) I get the following errors.

"../main.c", line 263: error #20: identifier "TA0CCTL3" is undefined
"../main.c", line 264: error #20: identifier "TA0CCR3" is undefined

With the MSP430FR5994 (on the MSP-EXP430FR5994 Development Kit) I should be able to define up to TA0CCR6. Any suggestions why this is not working?

Here is my code to configure the timers. I also use #include <msp430.h> in the code.

    TA0CTL |= TASSEL_1;             // Use ACLK as source
    TA0CTL |= ID_0;                 // Divide clock by 1
    TA0CTL |= MC_2;                 // Use CONTINUOUS mode timer
    TA0CTL |= TACLR;                // Clear timer

    TA0CCTL0 |= CCIE;               // Enable Interrupt on Timer
    TA0CCR0 = 5000;                 // Number of cycles in the timer

    TA0CCTL1 |= CCIE;               // Enable Interrupt on Timer
    TA0CCR1 = 10000;                // Number of cycles in the timer

    TA0CCTL2 |= CCIE;               // Enable Interrupt on Timer
    TA0CCR2 = 15000;                // Number of cycles in the timer

/*
These two lines create errors - TA0CCTL3 and TA0CCR3 are undefined.
See Table 25-8 in slau367o.pdf - should be able to define 7 counters.
*/

    TA0CCTL3 |= CCIE;               // Enable Interrupt on Timer
    TA0CCR3 = 20000;  		    // Number of cycles in the timer

    TA0IV = 0x0000;                 // Clear the interrupt flag

MSP430F1611: Timer_B Counter Issue.

$
0
0

Part Number:MSP430F1611

Dear All,

I am currently trying to build a counter that increments every 7.25ms.

My device is TelosB, which is MSP430F1611 with Crystal Oscilator of 32768Hz.

I set the Timer_B with ACLK which is the crystal and as time = number of counts/frequency.

To increment every 7.25ms, 328 counts are required.  Please refer to the code attached.

I have an issue, because two of capture/compare reigsters are occupied for radio capture and interval.

Here I declared

void sctimer_asncounter(void){
TBCCTL3 = CCIE;
TBCCR3 = 328;
TBCCTL3 |= CCIFG;
}


which triggers the appropriate interrupt handler.

case 0x0006: // CCR3 fires
if (TBCCTL3 & CCI){
if(sctimer_vars.asnreadcb !=NULL){
sctimer_vars.asnreadcb();
// kick the OS
return KICK_SCHEDULER;
}
}


where 

void cb_asnread(void){
app_vars.num_asn++;
uart_writeByte(app_vars.num_asn);

sctimer_asncounter();
sctimer_setCompare(sctimer_readCounter()+SCTIMER_PERIOD);

}


So it should constantly increases app_vars.numb_asn++ every 7.25ms but for somereason I can't even compile the code.

any help will be greatly appreicated.

Thank you.

(Please visit the site to view this file)(Please visit the site to view this file)

(Please visit the site to view this file)

MSP430F5529: Unusable ADC noise/jittering with TI's FRC Gamepad code

$
0
0

Part Number:MSP430F5529

I'm using the FRC Gamepad Tool to load the TI-supplied firmware for a USD HID joystick with a KMA210 magnetic angle sensor. I have a voltage divider taking the KMA210's 5V max output to 3.3V, and when plugging in the MSP and checking the windows game controllers, an axis does respond when I turn a magnet near the sensor, but the reading is all over the place. Bouncing back and forth by 40% of the whole angle range. I've tried using an external 5V supply, tried changing the sampling on the ADC, the Vref, the clock multiplier, the wires, the input pin, just about everything. 

Does anyone have any advice? 

MSP430F5529: Reading from ADC12 with driverlib - Always small value and sometimes never receives interrupt

$
0
0

Part Number:MSP430F5529

Hi

I am new to the MSP430 family, and any help will be appreciated.

I am trying to read from the onboard ADC. However I have 2 problems:

1. For some channel values (in the switch statement), no interrupt is called, so the processor gets stuck in the while loop waiting for the interrupt. (I know I need to add code to timeout of the loop)

2. For channel values where the interrupt is called, when I get the results it is always a small value <15.

Here is some code (heavily based on the example code in the DriverLib Users Guide:

In the main init function called at the top of main()

    // Initialize ADC12 with ADC12’s built-in oscillator
    ADC12_A_init(ADC12_A_BASE,
                 ADC12_A_SAMPLEHOLDSOURCE_SC,
                 ADC12_A_CLOCKSOURCE_ADC12OSC,
                 //ADC12_A_CLOCKDIVIDEBY_1);
                 ADC12_A_CLOCKDIVIDER_1);

My Function for reading from the ADC

uint16_t read_analog(int channel) {
    //Switch ON ADC12
    ADC12_A_enable(ADC12_A_BASE);

    // Setup sampling timer to sample-and-hold for 16 clock cycles
    ADC12_A_setupSamplingTimer(ADC12_A_BASE,
                               ADC12_A_CYCLEHOLD_64_CYCLES,
                               ADC12_A_CYCLEHOLD_4_CYCLES,                        
                               0);

    // Configure the Input to the Memory Buffer with the specified Reference Voltages
    ADC12_A_configureMemoryParam param = {0};
    param.memoryBufferControlIndex = ADC12_A_MEMORY_0 + channel;
    param.inputSourceSelect = ADC12_A_INPUT_A0 + channel;
    param.positiveRefVoltageSourceSelect = ADC12_A_VREFPOS_AVCC;
    param.negativeRefVoltageSourceSelect = ADC12_A_VREFNEG_AVSS;
    param.endOfSequence = ADC12_A_NOTENDOFSEQUENCE;
    ADC12_A_configureMemory(ADC12_A_BASE, &param);

    // Start a single conversion, no repeating or sequences.
    ADC12_A_startConversion(ADC12_A_BASE,
                            ADC12_A_MEMORY_0 + channel,
                            ADC12_A_SINGLECHANNEL);

    // Wait for the Interrupt Flag to assert
    // Get appropriate interrupt id, also if the argument is a channel we do not use, return -1
            switch (channel) {
            case 5 :
                while( !(ADC12_A_getInterruptStatus(ADC12_A_BASE,ADC12IFG5)) );
                break;
            case 6 :
                while( !(ADC12_A_getInterruptStatus(ADC12_A_BASE,ADC12IFG6)) );
                break;
            case 7 :
                while( !(ADC12_A_getInterruptStatus(ADC12_A_BASE,ADC12IFG7)) );
                break;
            case 12 :
                while( !(ADC12_A_getInterruptStatus(ADC12_A_BASE,ADC12IFG12)) );
                break;
            case 13 :
                while( !(ADC12_A_getInterruptStatus(ADC12_A_BASE,ADC12IFG13)) );
                break;
            default:
                return(-1);
            }

    // Get the value
    uint16_t data = ADC12_A_getResults(ADC12_A_BASE, ADC12_A_MEMORY_0 + channel);

    // Disable the ADC
    ADC12_A_disable(ADC12_A_BASE);

    return(data);
}

RTOS/MSP432P401R: UART with flow control stalls

$
0
0

Part Number:MSP432P401R

Tool/software:TI-RTOS

Hi,

I'm having trouble running UART at baud rate 115200 with flow control to a cellular module. I'm using Simplelink 1.40.00.28 on MSP432P401R Rev C.

On a stripped-down version of my project, a thread listens for UART packets from the cellular module and then sends it to another UART port for console display, and another thread (with a lower priority) initiates procedures for connecting to the cellular network. Here, UART communication runs smoothly and network communication can be maintained.

The UART module is then integrated into the full-scale project which runs more threads (for logging, routine functions, and I2C & SPI sensors). The UART listener thread still has the highest priority among the other threads. Here I encounter two issues:

1. The thread responsible for connecting to cellular network needs to wait for a long time between each UART transmission for the data to be sent and received successfully. Basically, I had to insert usleep(200000) between each UART instruction to the cellular module. (the number 200000 was obtained through trial and error)

2. When data of larger size is expected (here it is 130 bytes), the UART seems to stall and no data could be received at all.

Referring to errata USCI44 in slaz610m, both MCLK and SMCLK (which runs my UART clock) are driven by DCO, and I have not polled UCAxTXIFG and UCAxRXIFG. I have also increased the UART ring buffer size to 1024 but to no avail. Pls help on this.

Thanks,

Alvin

CCS/MSP430G2553: MSP430G2553 TOUCH Clock affects counting

$
0
0

Part Number:MSP430G2553

Tool/software: Code Composer Studio

Hello


I using MSP430G2553 and achieve touch detection by RO_PINOSC_TA0_WDTp Method , I encountered the following problems;
SMCLK is set to 1MHZ For a fixed capacitance change, the change in TA0CCR1 measurement is small and varies by approximately 5%.
SMCLK is set to the same capacitance change of 125KHZ. The TA0CCR1 measurement varies a lot, about 70%.
According to the measurement principle, the measurement window time becomes smaller, then TA0 counts base with smaller but does not affect the magnitude of change (this is my personal understanding do not know is correct).
This problem has been bothering me for a long time, please tell me why?


Thank you

Best regards

JackLiu

MSP430FR6989: MSP430FR6989

$
0
0

Part Number:MSP430FR6989

Board MSP_EXP430FR6989LP (platform msp430, package energia) is unknown 

I am getting this error during compiling. please help


Linux/MSP430F5529: MSP430F5529 I2C changed clock I2C blocked

$
0
0

Part Number:MSP430F5529

Tool/software: Linux

Hello and happy new year,

I changed the clock on my MSP430F5529 from a 20MHz to a 24MHz to be able to used USB-BSL and have high frequency clock. And since that, i can't seem to be able to send data via I2C.  I have tried to have the I2C frequency to 12MHz and 6MHz with SMCLK and ACLK but it doesn't seem to work, will i precedently had I2C at 10MHz with SMCLK on my 20MHz clock.

It doesn't seem to be an electrical issues since when i revert to a 20MHz clock it work.

So i'm asking for your help and your knowledge, please Help:

I use the TI library, my code:

clock.h/c:

#define CLOCK_RATE_MCLK        24000000
#define CLOCK_MS_MCLK        20000
#define CLOCK_RATE_SMCLK    12000000
#define CLOCK_RATE_ACLK        6000000

    GPIO_setAsPeripheralModuleFunctionInputPin(XT2_PIN_1);
    GPIO_setAsPeripheralModuleFunctionInputPin(XT2_PIN_2);
    
    //set speed clock acordingly to the speed authorized in the datasheet in the UCS chapter
    UCS_setExternalClockSource(32768,CLOCK_RATE_MCLK); // XT2=24MHz NO XT1

    // Set Vcore to accomodate for max. allowed system speed
    PMM_setVCore(PMM_CORE_LEVEL_3);

    //Init crystal (not meth)
    UCS_turnOnXT2(UCS_XT2_DRIVE_4MHZ_8MHZ);//hight frequency
    UCS_turnOffXT1();

    // Use the crystals to set the clocks; the slower the clock the less power consuption it take
    UCS_initClockSignal(UCS_MCLK,UCS_XT2CLK_SELECT,UCS_CLOCK_DIVIDER_1); // clock is at 24MHz
    UCS_initClockSignal(UCS_SMCLK,UCS_XT2CLK_SELECT,UCS_CLOCK_DIVIDER_2);// clock at 12MHz
    UCS_initClockSignal(UCS_ACLK,UCS_XT2CLK_SELECT,UCS_CLOCK_DIVIDER_4);//clock at 6MHz

I2C init:

GPIO_setAsPeripheralModuleFunctionOutputPin(PRESSURE_SENSOR_B1);

USCI_B_I2C_initMasterParam param;
param.selectClockSource = USCI_B_I2C_CLOCKSOURCE_ACLK;
param.i2cClk = CLOCK_RATE_ACLK;//6MHz
param.dataRate = USCI_B_I2C_SET_DATA_RATE_100KBPS;

USCI_B_I2C_initMaster(USCI_B1_BASE, &param);

USCI_B_I2C_setSlaveAddress(USCI_B1_BASE, add);

USCI_B_I2C_setMode(USCI_B1_BASE, USCI_B_I2C_TRANSMIT_MODE);

USCI_B_I2C_disableInterrupt(USCI_B1_BASE, USCI_B_I2C_TRANSMIT_INTERRUPT); USCI_B_I2C_disableInterrupt(USCI_B1_BASE, USCI_B_I2C_RECEIVE_INTERRUPT);

I2C send:

USCI_B_I2C_masterSendSingleByte(USCI_B1_BASE, data);
ms_delay(1);
USCI_B_I2C_clearInterrupt(USCI_B1_BASE, USCI_B_I2C_TRANSMIT_INTERRUPT);
USCI_B_I2C_clearInterrupt(USCI_B1_BASE, USCI_B_I2C_STOP_INTERRUPT);

Driver I2C FROM TI:

void USCI_B_I2C_masterSendSingleByte(uint16_t baseAddress,
                                     uint8_t txData)
{
    //Store current TXIE status
    uint8_t txieStatus = HWREG8(baseAddress + OFS_UCBxIE) & UCTXIE;

    //Disable transmit interrupt enable
    HWREG8(baseAddress + OFS_UCBxIE) &= ~(UCTXIE);

    //Send start condition.
    HWREG8(baseAddress + OFS_UCBxCTL1) |= UCTR + UCTXSTT;

    //Poll for transmit interrupt flag.
    while(!(HWREG8(baseAddress + OFS_UCBxIFG) & UCTXIFG))
    {
        ;
    }

    //Send single byte data.
    HWREG8(baseAddress + OFS_UCBxTXBUF) = txData;

    //Poll for transmit interrupt flag.
    while(!(HWREG8(baseAddress + OFS_UCBxIFG) & UCTXIFG))
    {
        ;//IS BLOOCKED HERE
    }

    //Send stop condition.
    HWREG8(baseAddress + OFS_UCBxCTL1) |= UCTXSTP;

    //Clear transmit interrupt flag before enabling interrupt again
    HWREG8(baseAddress + OFS_UCBxIFG) &= ~(UCTXIFG);

    //Reinstate transmit interrupt enable
    HWREG8(baseAddress + OFS_UCBxIE) |= txieStatus;
}

thanks,

Aurelia

MSP430F5529: Two MSP430F5529 Launch pads communication using UART (USCI_A0)

$
0
0

Part Number:MSP430F5529

Hello,

I am trying to send the character 'r' (0x72) from one msp430f5529 launchpad to other using UART. The other launchpad detects 'r' (0x72) and glows the LED at p1.0.

This is my Code for both the launchpads.

Transmitter

#include<msp430.h>

intmain(void)

{

WDTCTL = WDTPW + WDTHOLD; // Stop WDT

P3SEL |= BIT3+BIT4; // P3.3,4 = USCI_A0 TXD/RXD

UCA0CTL1 |= UCSWRST; // **Put state machine in reset**

UCA0CTL1 |= UCSSEL_2; // SMCLK

UCA0BR0 = 9; // 1MHz 115200 (see User's Guide)

UCA0BR1 = 0; // 1MHz 115200

UCA0MCTL |= UCBRS_1 + UCBRF_0; // Modulation UCBRSx=1, UCBRFx=0

UCA0CTL1 &= ~UCSWRST; // **Initialize USCI state machine**

//UCA0IE |= UCRXIE; // Enable USCI_A0 RX interrupt

while(1){

while(UCA0STAT & UCBUSY);

UCA0TXBUF = 0x72;

}

__no_operation(); // For Debugge

 

}

Receiver

#include<msp430.h>

unsignedint k;

intmain(void)

{

WDTCTL = WDTPW + WDTHOLD; // Stop WDT

P3SEL |= BIT3+BIT4; // P3.3,4 = USCI_A0 TXD/RXD

WDTCTL = WDTPW+WDTHOLD; // Stop WDT

P1DIR |= BIT0; // P1.0 set as output

P1OUT &= ~BIT0;

 

UCA0CTL1 |= UCSWRST; // **Put state machine in reset**

UCA0CTL1 |= UCSSEL_2; // SMCLK

UCA0BR0 = 9; // 1MHz 115200 (see User's Guide)

UCA0BR1 = 0; // 1MHz 115200

UCA0MCTL |= UCBRS_1 + UCBRF_0; // Modulation UCBRSx=1, UCBRFx=0

UCA0CTL1 &= ~UCSWRST; // **Initialize USCI state machine**

UCA0IE |= UCRXIE; // Enable USCI_A0 RX interrupt

__bis_SR_register(LPM0_bits + GIE); // Enter LPM0, interrupts enabled

__no_operation(); // For debugger

}

// Echo back RXed character, confirm TX buffer is ready first

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

#pragma vector=USCI_A0_VECTOR

__interruptvoidUSCI_A0_ISR(void)

#elif defined(__GNUC__)

void__attribute__ ((interrupt(USCI_A0_VECTOR))) USCI_A0_ISR (void)

#else

#error Compiler not supported!

#endif

{

switch(__even_in_range(UCA0IV,4))

{

case 0:break; // Vector 0 - no interrupt

case 2:

k = UCA0RXBUF; // TX -> RXed character

if (k == 0x72)

P1OUT |= BIT0;

break;

case 4:break; // Vector 4 - TXIFG

default: break;

}

}

I connected P3.3, P3.4 of tx launchpad to P3.4, P3.3 of rx launchpad resp. I am receiving garbage values in UCA0RXBUF and the led is not glowing.

Any mistakes I have done in the Code?

MSP430FR2111: MSP430FR2xx Family DIO SELC Register

$
0
0

Part Number:MSP430FR2111

These may be a rhetorical questions....

1) The MSP430FR2xx Family User Guide (slau445G) Section 7.4.11, describes the PxSELC Register. The MSP430FR2111 Datasheet (SLASE78B) Table 6-26 on page 50 does not list the aforementioned PxSELC register offsets, yet, the SDK Header File "msp430fr2111.h" does define offsets corresponding to PASSEL. I want to assume PASELC actually does exist in the hardware and I'm looking at an unintended omission in the datasheet. But I have to ask; which is correct the datasheet or header file? 

2) The Header File "msp430fr2111.h" also defines offsets for PJ. The existence of PJ in the 'FR2111 is not specified in the datasheet and (obviously) there are no corresponding pins for PJ in the hardware. Again, I want to assume that this is merely an artifact left over from other variants of the MSP430 memory space. But I'm obliged to ask; why is PJ included  in the header file? 

References: 

1) MSP430FR2xx Family User Guide (slau445G) 

2) MSP430FR2111 Datasheet (SLASE78B) 

3) msp430fr2111.h (SDK Header File) 

MSP432P401R: MSP432 SPI 3 wire increment issue

$
0
0

Part Number:MSP432P401R

Hello,

I am trying to modify the SPI 3 wire increment example provided with the MSP DriverLib to control a signal generator (SparkFun MiniGen, basically an AD9837). The MiniGen came with some functions for setting up the signal generator that were useful, and it seems I only need to send a few control bits through SPI to properly configure the generator.

However, I am running into an issue, as it seems the SPI data is actually not transmitting. I made quite a few changes to the example code, and my current project looks below:

/******************************************************************************
 * MSP432 SPI - 3-wire Master Incremented Data
 *
 * This example shows how SPI master talks to SPI slave using 3-wire mode.
 * Incrementing data is sent by the master starting at 0x01. Received data is
 * expected to be same as the previous transmission.  eUSCI RX ISR is used to
 * handle communication with the CPU, normally in LPM0. Because all execution 
 * after LPM0 is in ISRs, initialization waits for DCO to stabilize against 
 * ACLK.
 *
 * Note that in this example, EUSCIB0 is used for the SPI port. If the user
 * wants to use EUSCIA for SPI operation, they are able to with the same APIs
 * with the EUSCI_AX parameters.
 *
 * ACLK = ~32.768kHz, MCLK = SMCLK = DCO 3MHz
 *
 * Use with SPI Slave Data Echo code example.
 *
 *                MSP432P401
 *              -----------------
 *             |                 |
 *             |                 |
 *             |                 |
 *             |             P1.6|-> Data Out (UCB0SIMO)
 *             |                 |
 *             |             P1.7|<- Data In (UCB0SOMI)
 *             |                 |
 *             |             P1.5|-> Serial Clock Out (UCB0CLK)
 *******************************************************************************/
/* DriverLib Includes */
#include <ti/devices/msp432p4xx/driverlib/driverlib.h>
#include <ti/drivers/GPIO.h>
#include <ti/drivers/SPI.h>
#include "minigen.h"

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

/* Statics
static volatile uint8_t RXData = 0;
static uint8_t TXData = 0;*/

//![Simple SPI Config]
/* SPI Master Configuration Parameter */
const eUSCI_SPI_MasterConfig spiMasterConfig =
{
        EUSCI_B_SPI_CLOCKSOURCE_SMCLK,             // SMCLK Clock Source
        3000000,                                   // SMCLK = DCO = 3MHZ
        500000,                                    // SPICLK = 500khz
        EUSCI_B_SPI_MSB_FIRST,                     // MSB First
        EUSCI_B_SPI_PHASE_DATA_CHANGED_ONFIRST_CAPTURED_ON_NEXT,    // Phase
        EUSCI_B_SPI_CLOCKPOLARITY_INACTIVITY_HIGH, // High polarity
        EUSCI_B_SPI_3PIN                           // 3Wire SPI Mode
};
//![Simple SPI Config]

int main(void)
{
    /* Halting WDT  */
    WDT_A_holdTimer();

    //![Simple SPI Example]
    /* Selecting P1.5 P1.6 and P1.7 in SPI mode */
    GPIO_setAsPeripheralModuleFunctionInputPin(GPIO_PORT_P1,
            GPIO_PIN5 | GPIO_PIN6 | GPIO_PIN7, GPIO_PRIMARY_MODULE_FUNCTION);
    //primary module functions in MSP432 datasheet; P1.5 = BSLCLK, P1.6 SIMO, P1.7 SOMI

    /* Configuring SPI in 3wire master mode */
    SPI_initMaster(EUSCI_B0_BASE, &spiMasterConfig);

    /* Enable SPI module */
    SPI_enableModule(EUSCI_B0_BASE);

    /* Enabling interrupts */
    //SPI_enableInterrupt(EUSCI_B0_BASE, EUSCI_B_SPI_RECEIVE_INTERRUPT);
    //Interrupt_enableInterrupt(INT_EUSCIB0);
    //Interrupt_enableSleepOnIsrExit();
    //![Simple SPI Example]

    /* Polling to see if the TX buffer is ready */
    //while (!(SPI_getInterruptStatus(EUSCI_B0_BASE,EUSCI_B_SPI_TRANSMIT_INTERRUPT)));

    /* Transmitting data to slave */
    //minigen_reset();
    minigen_setMode(SQUARE);
    uint32_t newFreq = minigen_freqCalc(140000.0);
    minigen_adjustFreq(FREQ0, FULL, newFreq);
    //SPI_transmitData(EUSCI_B0_BASE, TXData);

    PCM_gotoLPM0();
    __no_operation();
}

//******************************************************************************
//
//This is the EUSCI_B0 interrupt vector service routine.
//
//******************************************************************************
void EUSCIB0_IRQHandler(void)
{/*
    uint32_t status = SPI_getEnabledInterruptStatus(EUSCI_B0_BASE);
    uint32_t jj;

    SPI_clearInterruptFlag(EUSCI_B0_BASE, status);

    if(status & EUSCI_B_SPI_RECEIVE_INTERRUPT)
    {
        /* USCI_B0 TX buffer ready?
        while (!(SPI_getInterruptStatus(EUSCI_B0_BASE, EUSCI_B_SPI_TRANSMIT_INTERRUPT)));

        RXData = SPI_receiveData(EUSCI_B0_BASE);

        /* Send the next data packet
        SPI_transmitData(EUSCI_B0_BASE, ++TXData);

        /* Delay between transmissions for slave to process information
        for(jj=50;jj<50;jj++);
    }
*/
}

I removed the ISR as it was causing the program to interrupt and sleep whenever any modifications to the SPI register were made. Was this ISR crucial in any way if I am not using SPI RX? That's the only thing I can think of that might have affected it in the above piece of code.

Below is the code for the MiniGen functions. As I mentioned, it is pretty simple on the face of it in that it only needs to send a few bit changes for each configuration. The only thing that I could think to be wrong here is that I am somehow using the SPI_transmitData function incorrectly. Can anyone point out what the issue might be here?

#include <ti/devices/msp432p4xx/driverlib/driverlib.h>
#include <ti/drivers/GPIO.h>
#include <ti/drivers/SPI.h>
#include "minigen.h"

void minigen_reset(){
    uint32_t defaultFreq = minigen_freqCalc(100.0);
    minigen_adjustFreq(FREQ0, FULL, defaultFreq);
    minigen_adjustFreq(FREQ1, FULL, defaultFreq);
    minigen_adjustPhaseShift(PHASE0, 0x0000);
    SPI_transmitData(EUSCI_B0_BASE, 0x0100);
    SPI_transmitData(EUSCI_B0_BASE, 0x0000);
}

// Set the mode of the part. The mode (trinagle, sine, or square) is set by
//  three bits in the status register: D5 (OPBITEN), D3 (DIV2), and D1 (MODE).
//  Here's a nice truth table for those settings:
//  D5 D1 D3
//  0  0  x   Sine wave output
//  0  1  x   Triangle wave output
//  1  0  0   Square wave @ 1/2 frequency
//  1  0  1   Square wave @ frequency
//  1  1  x   Not allowed
void minigen_setMode(MODE newMode){
    // We want to adjust the three bits in the config register that we're
    //  interested in without screwing up anything else. Unfortunately, this
    //  part is write-only, so we need to maintain a local shadow, adjust that,
    //  then write it.
    configReg &= ~0x002A; // Clear D5, D3, and D1.
    // This switch statement sets the appropriate bit in the config register.
    switch(newMode)
    {
        case TRIANGLE:
            configReg |= 0x0002;
        break;
        case SQUARE_2:
            configReg |=0x0020;
        break;
        case SQUARE:
            configReg |=0x0028;
        break;
        case SINE:
            configReg |=0x0000;
        break;
    }
    SPI_transmitData(EUSCI_B0_BASE, configReg); // Now write our shadow copy to the part.
}

// The AD9837 has two frequency registers that can be independently adjusted.
//  This allows us to fiddle with the value in one without affecting the output
//  of the device. The register used for calculating the output is selected by
//  toggling bit 11 of the config register.
void minigen_selectFreqReg(FREQREG reg)
{
    // For register FREQ0, we want to clear bit 11.
    if (reg == FREQ0) configReg &= ~0x0800;
    // Otherwise, set bit 11.
    else              configReg |= 0x0800;
    SPI_transmitData(EUSCI_B0_BASE, configReg);
}


// Similarly, there are two phase registers, selected by bit 10 of the config
//  register.
void  minigen_selectPhaseReg(PHASEREG reg)
{
  if (reg == PHASE0) configReg &= ~0x0400;
  else               configReg |= 0x0400;
  SPI_transmitData(EUSCI_B0_BASE, configReg);
}


// The frequency registers are 28 bits in size (combining the lower 14 bits of
//  two 16 bit writes; the upper 2 bits are the register address to write).
//  Bits 13 and 12 of the config register select how these writes are handled:
//  13 12
//  0  0   Any write to a frequency register is treated as a write to the lower
//          14 bits; this allows for fast fine adjustment.
//  0  1   Writes are send to upper 14 bits, allowing for fast coarse adjust.
//  1  x   First write of a pair goes to LSBs, second to MSBs. Note that the
//          user must, in this case, be certain to write in pairs, to avoid
//          unexpected results!
void minigen_setFreqAdjustMode(FREQADJUSTMODE newMode)
{
    // Start by clearing the bits in question.
    configReg &= ~0x3000;
    // Now, adjust the bits to match the truth table above.
    switch(newMode)
    {
        case COARSE:  // D13:12 = 01
            configReg |= 0x1000;
            break;
        case FINE:    // D13:12 = 00
            break;
        case FULL:    // D13:12 = 1x (we use 10)
            configReg |= 0x2000;
            break;
    }
    SPI_transmitData(EUSCI_B0_BASE, configReg);
}

// The phase shift value is 12 bits long; it gets routed to the proper phase
//  register based on the value of the 3 MSBs (4th MSB is ignored).
void minigen_adjustPhaseShift(PHASEREG reg, uint16_t newPhase)
{
    // First, let's blank the top four bits. Just because it's the right thing
    //  to do, you know?
    newPhase &= ~0xF000;
    // Now, we need to set the top three bits to properly route the data.
    //  D15:D13 = 110 for PHASE0...
    if (reg == PHASE0) newPhase |= 0xC000;
    // ... and D15:D13 = 111 for PHASE1.
    else               newPhase |= 0xE000;
    SPI_transmitData(EUSCI_B0_BASE, configReg);
}

// Okay, now we're going to handle frequency adjustments. This is a little
//  trickier than a phase adjust, because in addition to properly routing the
//  data, we need to know whether we're writing all 32 bits or just 16. I've
//  overloaded this function call for three cases: write with a mode change (if
//  one is needed), and write with the existing mode.

// Adjust the contents of the given register, and, if necessary, switch mode
//  to do so. This is probably the slowest method of updating a register.
void minigen_adjustFreq(FREQREG reg, FREQADJUSTMODE mode, uint32_t newFreq)
{
    minigen_setFreqAdjustMode(mode);

    // We need to split the 32-bit input into two 16-bit values, blank the top
    //  two bits of those values, and set the top two bits according to the
    //  value of reg.
    // Start by acquiring the low 16-bits...
    uint16_t temp = (uint16_t)newFreq;
    // ...and blanking the first two bits.
    temp &= ~0xC000;
    // Now, set the top two bits according to the reg parameter.
    if (reg==FREQ0) temp |= 0x4000;
    else            temp |= 0x8000;
    // Now, we can write temp out to the device.
    SPI_transmitData(EUSCI_B0_BASE, temp);
    // Okay, that's the lower 14 bits. Now let's grab the upper 14.
    temp = (uint16_t)(newFreq>>14);
    // ...and now, we can just repeat the process.
    temp &= ~0xC000;
    // Now, set the top two bits according to the reg parameter.
    if (reg==FREQ0) temp |= 0x4000;
    else            temp |= 0x8000;
    // Now, we can write temp out to the device.
    SPI_transmitData(EUSCI_B0_BASE, temp);
}

// Helper function, used to calculate the integer value to be written to a
//  freq register for a desired output frequency.
// The output frequency is fclk/2^28 * FREQREG. For us, fclk is 16MHz. We can
//  save processor time by specifying a constant for fclk/2^28- .0596. That is,
//  in Hz, the smallest step size for adjusting the output frequency.
uint32_t minigen_freqCalc(float desiredFrequency)
{
    return (uint32_t) (desiredFrequency/.0596);
}

MSP430FR5969: Strain Gauge Interface through ADC12_B with external amplifier

$
0
0

Part Number:MSP430FR5969

Hi all,

I am working on a design which includes a full-bridge strain gauge to measure tank pressure. It does not need to be rad-hard at this time, but I would like to be able deliver a rad-hard version in the future with minimal redesign. For this reason, the MSP430FR5969 (and its -SP version) are my best choice for the microcontroller. I am trying to decide if I can get away with using the internal 12 bit SAR ADC.

Unlike some MSP430s (such as MSP430F6736A), the ADC on the FR5969 does not have a programmable gain amplifier. Because of that, I am looking at using the THS4513 (fully differential) to provide the gain necessary for my strain gauge into the MSP430FR5969 ADC12 input. Have I made any obvious mistakes in setup here?

My intended supply voltage is 3V (single ended). According to the THS4513 datasheet, the input and out ranges are +/-400mV and +/-450mV around mid-rail.

Maximum bridge output voltage (with 3V supply): 486uV differential
Minimum bridge output voltage to be resolved: 1.6uV differential
ADC Vref+: 1.2V internal reference voltage (ADC12VRSEL = 0001b)
ADC Vref-: AVSS
ADC ENOB with differential input: 10.7 bits typical (Table 5.26 in datasheet - 2.5V Vref, not sure how much this drops with a 1.2V reference)
ADC settings: 12 bit unsigned, differential inputs (ADC12DIF =1b, ADC12DF = 0b, ADC12RES = 10b)
ADC Voltage resolution based on ENOB: 721uV

My calculations tell me that I need about 55dB of gain to match the 1.6uV differential output of the strain gauge to the 721uV sensitivity of the ADC. Part of my concern is that the open loop gain of the THS4513 is only 68dB, and shooting for 55dB of gain will require a large resistor (Rf of 267k with Rg of 47 ohms).

This design seems borderline to me. I could go ahead and order the THS4513 EVM and try it all out, but if my chances of success are low, I should go ahead and start looking for an external ADC which works well with the MPS430. As a side note, I don’t have any other external chips which will require an I2C/SPI/etc interface, which is one reason I am hesitant to add an external ADC.

 Thanks,
Paul

MSP430F1611: Comparing value with timer value and synchronise.

$
0
0

Part Number:MSP430F1611

Dear all,

Due to your contribution, I have made some huge progress and I am reaching to my milestone that I have set.

I have a timer to increment every 237 ticks, which is stored as app_vars.num_asn, and every approximately 6seconds the app_vars.num_asn will print its corresponding count number.

Now, I have another value app_vars.ASN;representing a type of sequence number retrieved from network, and stored as uint64_t.

app_vars.num_asn should always be referred back to app_vars.ASN and synchronise to this number, if app_vars.num_asn - app_vars.ASN > 15  || app_vars.ASN - app_vars.num_asn > 15.

I got upto app_vars.num_asn  printing its corresponding count number and compare with app_vars.ASN, and if they are not equal to each other all of my led will turn on and be equalise to app_vars.ASN.

Looking at the function below, it should also then turn all LEDs off because initially the counter will always be smaller than the value of app_vars.ASN, however, it doesn't.

void cb_asnread(void){

app_vars.num_asn++;
if ((app_vars.num_asn % 885 ) == 0 ){
uart_writeByte(app_vars.num_asn);
while (app_vars.num_asn != app_vars.ASN){
leds_all_on();
if(app_vars.num_asn < app_vars.ASN){
leds_all_off();
app_vars.num_asn = app_vars.ASN;
}

//app_vars.num_asn = app_vars.ASN;
//leds_all_off();
}
}
}

Codes are attached in this post. 01bsp_radio_rx  is the main code.

Any help will be greatly appreciated!

Happy New year to all!

Thank you.

(Please visit the site to view this file)

(Please visit the site to view this file)

(Please visit the site to view this file)

MSP430F2471: MSP430F2471

$
0
0

Part Number:MSP430F2471

I had interfaced a humidity sensor by going through the datasheet, user guide and application report.  I have some issues related to i2c.

ACKNOWLEDGMENT NOT GIVEN FROM THE SENSOR

Issues

  1. Acknowledgement not given from the sensor after writing the start, write address byte of the slave, stop.
  2. Is the pulse width of the SCL is correct?

Things I have done to generate clock and data:

***************************************************

 UCB1BR0 = 12;                                           // fSCL =SMCLK/12 = ~100kHz

 UCB1BR1 = 0;

 UCB1I2CSA = 0x51;                                  // default  slave address (0x28 )given in the sensor data sheet

 *******Continuous loop for Start,and Stop and Write address of Slave *****************

 while(1)

{

UCB1CTL1 |= UCTXSTT;                       // I2C start condition

UCB1CTL1 |= UCTXSTP;                      // Generate I2C stop condition

}

Other than above I have set necessary configurations for USCI module.

My question as per I2C protocol and data sheet gave the Start sequence, 7-bit slave address, and write bit the calculated byte for the slave write address 0x28 are 0x51.

So I have set  UCB1I2CSA = 0x51.

So, after transmitting start, slave write address the acknowledgment has to be given from the sensor in the 9th clock pulse by making the SDA line low which is not happening.

The clock pulses generated are like spikes. Are they correct? Is there anything wrong with the clock pulses.

Can anyone help me to analyze this situation? I have seen this response from the CRO.


MSP430F2101: After Timer inttrupt microcontroller resets what could be wrong. its is a simple timer

$
0
0

Part Number:MSP430F2101

;-----------------------------------------------------------------------
#include <msp430x21x1.h> ; Header file for this device
;-----------------------------------------------------------------------
; Pins for LED on port 2
LED1 EQU BIT0 ; Relay port
LED2 EQU BIT1 ; Timer led blinking mode
Start EQU BIT2 ;start of timer
Select EQU BIT3 ;timer selection
#define Display R7
#define Time R6
#define delay 20
;counter EQU 20 ;3*60*10 ; 3 is multiple factor(3*60=1 minute).
;-----------------------------------------------------------------------
RSEG CSTACK ; Create stack (in RAM)
;-----------------------------------------------------------------------
RSEG CODE ; Program goes in code memory
Reset: ; Execution starts here
mov.w #SFE(CSTACK),SP ; Initialize stack pointer
; mov.w #1,R6
; bic.w #GIE,SR
; Equivalent to start of main() in C
main: mov.w #WDTPW|WDTHOLD,&WDTCTL ; Stop watchdog timer
; mov.b #LED2,&P2OUT ; Preload LED1 on, LED2 off
bic.b #LED1|LED2,&P2OUT
bis.b #LED1|LED2,&P2DIR ; Set pins with LED1,2 to output
bis.b #LED2 ,&P2OUT



bic.b #Start|Select, &P2DIR ; start & select pin direction as input
bis.b #Start|Select, &P2REN ; start & select pin pull up resistor enable
bis.b #Start|Select,&P2OUT ;Make the pull up pull up not down.forever
; mov.w #counter,R5
mov.w #1,R6 ; initial state of timer

mov.w #delay,&TACCR0 ; Period for up mode
mov.w #CCIE,&TACCTL0 ; Enable interrupts on Compare 0
mov.w #MC_1|ID_3|TASSEL_2|TACLR,&TACTL ; Set up Timer A
bis.w #GIE,SR
dint
; Up mode, divide clock by 8, clock from SMCLK, clear TAR
call #DISPLAY

aa:
; call #Time_Set
; call #Load_Data ; load set time to counter R5
; mov.w #counter,R5
bit.b #Start, &P2IN ; BIT P2.0 CHECK IF PRESSED
; CALL #DELAY_1S ; DEBOUNCE TIME 1 SEC
JNZ aa
mov.w #5400d,R5


aa:
eint
; Loop forever; interrupts do all!
bis.b LED1,&P2OUT ;Relay ON
; call #Sw_Check
; mov.w #5400d,R5
cmp.w #0,R5
jne aa

again:
dint
; bic.w #GIE,SR ; Disable interrupts
bic.b #LED1,&P2OUT ;Relay OFF
bis.b #LED2,&P2OUT

jmp main

DELAY_1S:
ret

mov.w #65000,R12 ;value should be >2500
d1: dec.w R5
jnz d1
ret
;////////////////////////////////////////////////////////////////////
Time_Set:
bit.b #Select, &P2IN ; BIT P2.0 CHECK IF PRESSED
; CALL #DELAY_1S ; DEBOUNCE TIME 1 SEC
JZ Setup
jmp Exit
Setup:
inc Time
; call #DISPLAY
cmp #9,Time
jne Exit
mov #1,Time
Exit:
call #DISPLAY
; CALL #DELAY_1S ; DEBOUNCE TIME 1 SEC
ret

;////////////////////////////////////////////////////////////////////
/*
Load_Data :
mov.w (Data_Load)(R6),R5
; mov.b DispReg,&P1OUT
ret
*/
;//////////////////////////////////////////////////////////////////

DISPLAY:
mov.b (Data_Dis)(R6),&P1OUT
; mov.w (Data_Load)(R6),R5 ; time loaded to counter
cmp #1,R6
JZ One
cmp #2,R6
JZ Two
cmp #3,R6
JZ Three
cmp #4,R6
JZ Four
cmp #5,R6
JZ Five
cmp #6,R6
JZ Six
cmp #7,R6
JZ Seven
cmp #8,R6
JZ Eight

One:
mov.w #5400d,R5 ;30 mins (=3*60*30)
ret
Two:
mov.w #10800d,R5 ;1 Hour
ret
Three:
mov.w #16200d,R5 ;1.5 Hour
ret
Four:
mov.w #21600d,R5 ;2 Hour
ret
Five:
mov.w #27000d,R5 ;2.5 Hour
ret
Six:
mov.w #32400d,R5 ;3 Hour
ret
Seven:
mov.w #37800d,R5 ;3.5 Hour
ret
Eight:
mov.w #43200d,R5 ;4 Hour
ret
;/////////////////////////////////////////////////////////////////
/*
Sw_Check:
bit.b #Start, &P2IN ; BIT start CHECK IF PRESSED
JZ Check_1
ret

Check_1:
; CALL #DELAY_1S ; DEBOUNCE TIME 1 SEC
bit.b #Start, &P2IN ; BIT start CHECK IF PRESSED
jnz ss
jmp main
ss:
ret
*/
;//////////////////////////////////////////////////////////////////


;ORG 01000h

Data_Dis
DB “0d,1d,2d,4d,8d,16d,32d,64d,128d“


;Data_Load
;DW “0d,5400,10800,16200,21600,27000,32400,37800,43200“


; time is 30,60,90,120,150,180,210,240 minutes
; total time is 4 hours
/*

ORG 01000h

Data_Dis
DB 00000000b
DB 00000001b
DB 00000010b
DB 00000100b
DB 00001000b
DB 00010000b
DB 00100000b
DB 01000000b
DB 10000000b
*/
;////////////////////////////////////////////////////////////////////
;-----------------------------------------------------------------------
; Interrupt service routine for TACCR0, called when TAR = TACCR0
; No need to acknowledge interrupt explicitly - done automatically
TA0_ISR: ; ISR for TACCR0 CCIFG


xor.b #LED2,&P2OUT ; Toggle LEDs
reti ; That's all: return from interrupt
;-----------------------------------------------------------------------
COMMON INTVEC ; Segment for vectors (in Flash)
ORG TIMERA0_VECTOR
DW TA0_ISR ; ISR for TA0 interrupt
ORG RESET_VECTOR
DW Reset ; Address to start execution
END

MSP430G2553: VLO range

$
0
0

Part Number:MSP430G2553

Dear Champs,

Because customer hope to calibrate VLO frequency temperature drift by lookup table, they need to know the min and max value for VLO range.

Our datasheet only have written typical value. 

Could you kindly provide the min and max value for VLO  frequency temperature drift?

If you have any suggestion, please feel free to let me know.

Thanks a lot.

MSP430F5172: How to set the external 8M crystal as the default clock?

$
0
0

Part Number:MSP430F5172

Dear TI engineers,

       I want to use the external 8M crystal as the default clock for the system,and  I have seen the examples  of TI,  but the resources are few, and I don't understand how to configure it.I need help.

 

Best regards,

Jeff Wong,

MSP430FR2000: Find a fast start-up power-on mcu less than 10us

$
0
0

Part Number:MSP430FR2000

In our project, we wanna use wiegand sensor to count the times while it activated when system is out of power.

Wiegand sensor could generate a 10us width regulatered pluse after it activated, we wanna using this pluse to power the chip and read --> increase/decrease --> store the counter, and when the system is powered-on, other mcu could read the counter register from this chip.

So, we need fram to achieve this, and MSP430FR series already embeded fram, I wanna know is there exists a type of mcu in TI could achieve power on then do above procedure in 10us?

If you got some information, please let me know and thanks for your help.

Zheng

MSP432P401R: SimpleLink™ MSP432P401R LaunchPad™ Development Kit Hardware Revision Changes?

$
0
0

Part Number:MSP432P401R

Hi all,

i just received some of the new harware Rev 2.1 ( SimpleLink™ MSP432P401R LaunchPad™ Development Kit )

I cant find any notes on the changes between 2.0 and 2.1.

When asking the support, i got this answer:

Thank you for contacting Texas Instruments. Y

Unfortunately, i cannot find any documentation regarding this new review 2.1, in the datasheet, I can see only the difference between 1.0 and 2.0(page 18):

http://www.ti.com/lit/ug/slau597d/slau597d.pdf

Please could you post your request in our forum, for sure our engineers can help you:

https://e2e.ti.com

Could you guys kindly describe the changes between Rev 2.0 and Rev 2.1 ?

 

Thanks in advance

 

Simon

Viewing all 21977 articles
Browse latest View live


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