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

CCS/MSP430FR5738: Which data types to use

$
0
0

Part Number:MSP430FR5738

Tool/software: Code Composer Studio

Hi,

I am using CCS with the MSP430Fr5738 developing an ultra low-power application. The MCU will be asleep most of its lifetime with regular wake-up intervals about twice an hour.

I am wondering if there are recommended data types to use to optimize the code as much as possible for the MSP430? or is the int,char,unsigned variables the way to go?


RTOS/MSP432E401Y: XDS110 UART Display using UART1

$
0
0

Part Number:MSP432E401Y

Tool/software: TI-RTOS

My current configuration uses all GPIO pins in port A, but for testing purposes I would still like to receive debug serial output via the xds 110 on the development board.    Therefore I have been trying unsuccessfully to configure UART1 and use pins PB0 and PB1 for display UART RX and TX respectively.   

Here are my UART and Display configurations in the MSP_EXP432E401Y.c file:

/*
 *  =============================== UART ===============================
 */
#include <ti/drivers/UART.h>
#include <ti/drivers/uart/UARTMSP432E4.h>

UARTMSP432E4_Object uartMSP432E4Objects[MSP_EXP432E401Y_UARTCOUNT];
unsigned char uartMSP432E4RingBuffer[MSP_EXP432E401Y_UARTCOUNT][32];

/* UART configuration structure */
const UARTMSP432E4_HWAttrs uartMSP432E4HWAttrs[MSP_EXP432E401Y_UARTCOUNT] = {
    {
        .baseAddr = UART0_BASE,
        .intNum = INT_UART0,
        .intPriority = (~0),
        .flowControl = UARTMSP432E4_FLOWCTRL_NONE,
        .ringBufPtr  = uartMSP432E4RingBuffer[MSP_EXP432E401Y_UART0],
        .ringBufSize = sizeof(uartMSP432E4RingBuffer[MSP_EXP432E401Y_UART0]),
        .rxPin = /*UARTMSP432E4_PB0_U1RX,*/UARTMSP432E4_PA0_U0RX,
        .txPin = /*UARTMSP432E4_PB1_U1TX,*/UARTMSP432E4_PA1_U0TX,
        .ctsPin = UARTMSP432E4_PIN_UNASSIGNED,
        .rtsPin = UARTMSP432E4_PIN_UNASSIGNED,
        .errorFxn = NULL
    },
    {
        .baseAddr = UART1_BASE,
        .intNum = INT_UART1,
        .intPriority = (~0),
        .flowControl = UARTMSP432E4_FLOWCTRL_NONE,
        .ringBufPtr  = uartMSP432E4RingBuffer[MSP_EXP432E401Y_UART1],
        .ringBufSize = sizeof(uartMSP432E4RingBuffer[MSP_EXP432E401Y_UART1]),
        .rxPin = UARTMSP432E4_PB0_U1RX,//UARTMSP432E4_PA0_U0RX,
        .txPin = UARTMSP432E4_PB1_U1TX,//UARTMSP432E4_PA1_U0TX,
        .ctsPin = UARTMSP432E4_PIN_UNASSIGNED,
        .rtsPin = UARTMSP432E4_PIN_UNASSIGNED,
        .errorFxn = NULL
    }
};

const UART_Config UART_config[MSP_EXP432E401Y_UARTCOUNT] = {
    {
        .fxnTablePtr = &UARTMSP432E4_fxnTable,
        .object = &uartMSP432E4Objects[MSP_EXP432E401Y_UART0],
        .hwAttrs = &uartMSP432E4HWAttrs[MSP_EXP432E401Y_UART0]
    },
    {
        .fxnTablePtr = &UARTMSP432E4_fxnTable,
        .object = &uartMSP432E4Objects[MSP_EXP432E401Y_UART1],
        .hwAttrs = &uartMSP432E4HWAttrs[MSP_EXP432E401Y_UART1]
    }
};

const uint_least8_t UART_count = MSP_EXP432E401Y_UARTCOUNT;


/*
 *  ============================= Display =============================
 */
#include <ti/display/Display.h>
#include <ti/display/DisplayUart.h>
#include <ti/display/DisplaySharp.h>
#define MAXPRINTLEN 1024

#ifndef BOARD_DISPLAY_SHARP_SIZE
#define BOARD_DISPLAY_SHARP_SIZE    96
#endif

DisplayUart_Object     displayUartObject;
DisplaySharp_Object    displaySharpObject;

static char displayBuf[MAXPRINTLEN];
//static uint_least8_t sharpDisplayBuf[BOARD_DISPLAY_SHARP_SIZE * BOARD_DISPLAY_SHARP_SIZE / 8];


const DisplayUart_HWAttrs displayUartHWAttrs = {
    .uartIdx = MSP_EXP432E401Y_UART1,
    .baudRate = 115200,
    .mutexTimeout = (unsigned int)(-1),
    .strBuf = displayBuf,
    .strBufLen = MAXPRINTLEN
};

#ifndef BOARD_DISPLAY_USE_UART
#define BOARD_DISPLAY_USE_UART 1
#endif
#ifndef BOARD_DISPLAY_USE_UART_ANSI
#define BOARD_DISPLAY_USE_UART_ANSI 0
#endif
#ifndef BOARD_DISPLAY_USE_LCD
#define BOARD_DISPLAY_USE_LCD 0
#endif

/*
 * This #if/#else is needed to workaround a problem with the
 * IAR compiler. The IAR compiler doesn't like the empty array
 * initialization. (IAR Error[Pe1345])
 */
 #if (BOARD_DISPLAY_USE_UART || BOARD_DISPLAY_USE_LCD)
const Display_Config Display_config[] = {
    {
#  if (BOARD_DISPLAY_USE_UART_ANSI)
        .fxnTablePtr = &DisplayUartAnsi_fxnTable,
#  else /* Default to minimal UART with no cursor placement */
        .fxnTablePtr = &DisplayUartMin_fxnTable,
#  endif
        .object = &displayUartObject,
        .hwAttrs = &displayUartHWAttrs
    },
#endif
#if (BOARD_DISPLAY_USE_LCD)
    {
        .fxnTablePtr = &DisplaySharp_fxnTable,
        .object      = &displaySharpObject,
        .hwAttrs     = &displaySharpHWattrs
    },
#endif
};


const uint_least8_t Display_count = sizeof(Display_config) / sizeof(Display_Config);

And here is my UART cfg enum in the MSP432E401Y.h file:

/*!
 *  @def    MSP_EXP432E401Y_UARTName
 *  @brief  Enum of UARTs on the MSP_EXP432E401Y dev board
 */
typedef enum MSP_EXP432E401Y_UARTName {
    MSP_EXP432E401Y_UART0 = 0,
    MSP_EXP432E401Y_UART1,

    MSP_EXP432E401Y_UARTCOUNT
} MSP_EXP432E401Y_UARTName;

I open the display in the main function as follows:

 /* Call driver init functions */
    Board_initGeneral();
    Display_init();

    /* define display for UART console output */
    display = Display_open(Display_Type_UART, NULL);
    if (display == NULL) {
        /* Failed to open display driver */
        while(1);
    }

If I disable my GPIO configurations for Port A pins 0 and 1, and then change my DisplayUart_HWAttrs struct param .uartIdx to MSP_EXP432E401Y_UART0, everything works and I get display output, but changing to MSP_EXP432E401Y_UART1 I no longer receive serial display output. 

Is there a way for me to do what I want?   I couldn't see any info in the documentation references indicating that this is not possible.   

Thanks for any help you can provide.

Patrick

CCS/MSP-EXP430FR4133: About UART transmit signal while the lights turns round

$
0
0

Part Number:MSP-EXP430FR4133

Tool/software: Code Composer Studio

Hi!

First of all, I have to admit that I am absolutely new to both C language and microcontroller.

I have asked a question before about communication through UART and I have been directed to CCS.

However, when I try to simply combine two different code together, there are some problems.

I have been taught before and got a code about turning lights blinking as a circle(It really works!) But when I add UART_01 code to it, the MSP430 can only communicate with PC but the light part doesn't work. Why did that happen?

Here is my code for it.   I use IAR for my work. Waiting for reply

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

#include <msp430.h>
#include <driverlib.h>
#include "LedDriver.h"

void Init_GPIO();


int main(void)
{
//Default MCLK = 1MHz

unsigned int i = 0;
unsigned char dialValue = 0x01; //ask the first light to turn on
unsigned int pinState;
unsigned int lastState=1;
unsigned int dialGoingCW=1;
WDTCTL = WDTPW | WDTHOLD; // Stop watchdog timer

initialiseLedDial();
//Switch 1 //configure a pin as an input
GPIO_setAsInputPinWithPullUpResistor(GPIO_PORT_P1, GPIO_PIN3);



// Disable the GPIO power-on default high-impedance mode
// to activate previously configured port settings
PMM_unlockLPM5();



// Configure GPIO
Init_GPIO();
PM5CTL0 &= ~LOCKLPM5; // Disable the GPIO power-on default high-impedance mode
// to activate 1previously configured port settings

__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; // DCODIV = 8MHz
__delay_cycles(3);
__bic_SR_register(SCG0); // enable FLL
while(CSCTL7 & (FLLUNLOCK0 | FLLUNLOCK1)); // Poll until FLL is locked

CSCTL4 = SELMS__DCOCLKDIV | SELA__REFOCLK; // set default REFO(~32768Hz) as ACLK source, ACLK = 32768Hz
// default DCODIV as MCLK and SMCLK source

// Configure UART pins
P1SEL0 |= BIT0 | BIT1; // set 2-UART pin as second function

// Configure UART
UCA0CTLW0 |= UCSWRST;
UCA0CTLW0 |= UCSSEL__SMCLK;

// Baud Rate calculation
// 8000000/(16*9600) = 52.083
// Fractional portion = 0.083
// User's Guide Table 14-4: UCBRSx = 0x49
// UCBRFx = int ( (52.083-52)*16) = 1
UCA0BR0 = 52; // 8000000/16/9600
UCA0BR1 = 0x00;
UCA0MCTLW = 0x4900 | UCOS16 | UCBRF_1;

UCA0CTLW0 &= ~UCSWRST; // Initialize eUSCI
UCA0IE |= UCRXIE; // Enable USCI_A0 RX interrupt

__bis_SR_register(LPM3_bits|GIE); // Enter LPM3, interrupts enabled
__no_operation(); // For debugger






while(1) //every step on mean function will recall this part to test button state
{
//test button state
pinState = GPIO_getInputPinValue(GPIO_PORT_P1, GPIO_PIN3);

if(lastState==1)//botton not being pressed
{
if(pinState==0)
{
dialGoingCW=!dialGoingCW;
__delay_cycles(10000);//Dealy 10 ms;
}
}
lastState=pinState;

//updated value
if(1==dialGoingCW)
{
dialValue = dialValue * 0x02;
if(0x00 == dialValue)
dialValue = 0x01;
}
else
{
dialValue = dialValue / 0x02;
if(0x00 == dialValue)
dialValue = 0x80;
}

//Set value
setLedDial(dialValue);

//Refresh display (10 times for each position)
for(i = 0; i < 10; i++)
refreshLedDial();

}
}


#if defined(__TI_COMPILER_VERSION__) || defined(__IAR_SYSTEMS_ICC__)
#pragma vector=USCI_A0_VECTOR
__interrupt void USCI_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,USCI_UART_UCTXCPTIFG))
{
case USCI_NONE: break;
case USCI_UART_UCRXIFG:
while(!(UCA0IFG&UCTXIFG));
UCA0TXBUF = UCA0RXBUF;
__no_operation();
break;
case USCI_UART_UCTXIFG: break;
case USCI_UART_UCSTTIFG: break;
case USCI_UART_UCTXCPTIFG: break;
default: break;
}
}


void Init_GPIO()
{
P1DIR = 0xFF; P2DIR = 0xFF; P3DIR = 0xFF; P4DIR = 0xFF;
P5DIR = 0xFF; P6DIR = 0xFF; P7DIR = 0xFF; P8DIR = 0xFF;
P1REN = 0xFF; P2REN = 0xFF; P3REN = 0xFF; P4REN = 0xFF;
P5REN = 0xFF; P6REN = 0xFF; P7REN = 0xFF; P8REN = 0xFF;
P1OUT = 0x00; P2OUT = 0x00; P3OUT = 0x00; P4OUT = 0x00;
P5OUT = 0x00; P6OUT = 0x00; P7OUT = 0x00; P8OUT = 0x00;
}

MSP430F5438A-EP: Verifying pins affected by errata PORT16

$
0
0

Part Number:MSP430F5438A-EP

Hello,

I would like to use the MSP430F5438A-EP in a design, but I want to make sure I'm aware of which pins are affected by the PORT16 errata issue. The issue states, 

"During device start-up, all of the GPIO pins are expected to be in the floating input state. Due to this erratum, some of the GPIO pins are driven low for the duration of boot code execution during device start-up, if an external reset event (via the RST pin) interrupted the previous boot code execution. Boot code is always executed after a BOR, and the duration of this boot code execution is approximately 500us. For a given device family, this erratum affects only the GPIO pins that are not available in the smallest package device family member, but that are present on its larger package variants."

However, I am confused on what is considered a "device family". Are all the parts that start with MSP430F5XXX part of the same family? Because then I think the smallest family member would be the MSP430F5151 in the 38-pin package. However, the MSP4305438A-EP datasheet only has a 100-pin and 113-pin package listed, so would the smallest member be the 100-pin package?

Clarification on this would be appreciated.

Thanks.

RTOS/MSP432E401Y: SDRAM as Default Heap

$
0
0

Part Number:MSP432E401Y

Tool/software: TI-RTOS

Hi,

I have a tirtos project that I would like to, at least, have malloc() pull from external SDRAM. Being able to assign specific task stacks to SDRAM would also be useful. Can someone show me how this is done?  On a previous project with a different RTOS there was a call to set the default memory pool.  This did not require any linker modifications. Simply pass in the address and size.

Thanks,

-Mike

MSP430F5529: SPI communication sending bytes twice

$
0
0

Part Number:MSP430F5529

Hello,

I am trying to connect Raspberry pi 3 B + with the MSP430f5529 (launchpad) using SPI communication but I seem to encounter an error I can't get around.

The SPI communication is a 3 wire connection with the Raspberry being the master and the MSP the slave. I have made sure that all the SPI parameters are OK (clock polarity and phase, etc...). The program consists simply in the raspberry sending a command (TX_CMD) in order to make the MSP read a sensor (not implemented yet, simulated as an array being modified) and then send back 4096 bytes (maximum supported by Raspberry buffer).

The problem is that the MSP sends twice the first byte to transmit (after receiving the TX_CMD), so the last byte is not sent. I have also seen that when I increase the SPI CLK frequency, more than just the first byte is sent twice. I thought it might be the SYS clock not being able to keep up with the SPI interrupt frequency, but after increasing the MCLK speed to 20MHz I stilll have the same error. The program runs fine for low frequencies, but are too low for an SPI communication (around 120KHz).

I don't usually post in forums, if any info is required just ask. I leave the code here:

#include <msp430.h> 
#include <stdint.h>
#include <stdbool.h>



#define SLAVE_CS_IN     P2IN
#define SLAVE_CS_DIR    P2DIR
#define SLAVE_CS_PIN    BIT0


#define IT_CMD 11
#define TX_CMD 22


void CopyArray(uint8_t *source, uint8_t *dest, uint8_t count)
{
    uint8_t copyIndex = 0;
    for (copyIndex = 0; copyIndex < count; copyIndex++)
    {
        dest[copyIndex] = source[copyIndex];
    }
}

//INIT FUNCTIONS
void initGPIO()
{
  //LEDs
  P1OUT = 0x00;                             // P1 setup for LED & reset output
  P1DIR |= BIT0 + BIT5;

  P4DIR |= BIT7;
  P4OUT &= ~(BIT7);

  //SPI Pins
  P3SEL |= BIT3 + BIT4;                     // P3.3,4 option select
  P2SEL |= BIT7;                            // P2.7 option select

  /*
  P2SEL |= BIT2;        //PARA MIRAR LA FRECUENCIA DEL SMCLK EN EL PIN 2.2
  P2DIR |=   BIT2;
  */
}

void initSPI()
{
  //Clock Polarity: The inactive state is high
  //MSB First, 8-bit, Master, 3-pin mode, Synchronous
  UCA0CTL1 = UCSWRST;                       // **Put state machine in reset**
  UCA0CTL0 |=  UCMSB + UCSYNC;// +UCCKPH;      // 3-pin, 8-bit SPI Slave
  UCA0CTL1 &= ~UCSWRST;                     // **Initialize USCI state machine**
  UCA0IE |= UCRXIE;                          // Enable USCI0 RX interrupt

  SLAVE_CS_DIR &= ~(SLAVE_CS_PIN);

}

void initClockTo16MHz()
{
    UCSCTL3 |= SELREF_2;                      // Set DCO FLL reference = REFO
    UCSCTL4 |= SELA_2;                        // Set ACLK = REFO
    __bis_SR_register(SCG0);                  // Disable the FLL control loop
    UCSCTL0 = 0x0000;                         // Set lowest possible DCOx, MODx
    UCSCTL1 = DCORSEL_6; //DCORSEL_5;                      // Select DCO range 16MHz operation
    UCSCTL2 = FLLD_0 + 762;//487;                   // Set DCO Multiplier for 16MHz
                                              // (N + 1) * FLLRef = Fdco
                                              // (487 + 1) * 32768 = 16MHz
                                              // Set FLL Div = fDCOCLK
    __bic_SR_register(SCG0);                  // Enable the FLL control loop

    // Worst-case settling time for the DCO when the DCO range bits have been
    // changed is n x 32 x 32 x f_MCLK / f_FLL_reference. See UCS chapter in 5xx
    // UG for optimization.
    // 32 x 32 x 16 MHz / 32,768 Hz = 500000 = MCLK cycles for DCO to settle
    __delay_cycles(500000);//
    // Loop until XT1,XT2 & DCO fault flag is cleared
    do
    {
        UCSCTL7 &= ~(XT2OFFG + XT1LFOFFG + DCOFFG); // Clear XT2,XT1,DCO fault flags
        SFRIFG1 &= ~OFIFG;                          // Clear fault flags
    }while (SFRIFG1&OFIFG);                         // Test oscillator fault flag
}

uint16_t setVCoreUp(uint8_t level){
    uint32_t PMMRIE_backup, SVSMHCTL_backup, SVSMLCTL_backup;

    //The code flow for increasing the Vcore has been altered to work around
    //the erratum FLASH37.
    //Please refer to the Errata sheet to know if a specific device is affected
    //DO NOT ALTER THIS FUNCTION

    //Open PMM registers for write access
    PMMCTL0_H = 0xA5;

    //Disable dedicated Interrupts
    //Backup all registers
    PMMRIE_backup = PMMRIE;
    PMMRIE &= ~(SVMHVLRPE | SVSHPE | SVMLVLRPE |
                SVSLPE | SVMHVLRIE | SVMHIE |
                SVSMHDLYIE | SVMLVLRIE | SVMLIE |
                SVSMLDLYIE
                );
    SVSMHCTL_backup = SVSMHCTL;
    SVSMLCTL_backup = SVSMLCTL;

    //Clear flags
    PMMIFG = 0;

    //Set SVM highside to new level and check if a VCore increase is possible
    SVSMHCTL = SVMHE | SVSHE | (SVSMHRRL0 * level);

    //Wait until SVM highside is settled
    while((PMMIFG & SVSMHDLYIFG) == 0)
    {
        ;
    }

    //Clear flag
    PMMIFG &= ~SVSMHDLYIFG;

    //Check if a VCore increase is possible
    if((PMMIFG & SVMHIFG) == SVMHIFG)
    {
        //-> Vcc is too low for a Vcore increase
        //recover the previous settings
        PMMIFG &= ~SVSMHDLYIFG;
        SVSMHCTL = SVSMHCTL_backup;

        //Wait until SVM highside is settled
        while((PMMIFG & SVSMHDLYIFG) == 0)
        {
            ;
        }

        //Clear all Flags
        PMMIFG &= ~(SVMHVLRIFG | SVMHIFG | SVSMHDLYIFG |
                     SVMLVLRIFG | SVMLIFG |
                     SVSMLDLYIFG
                     );

        //Restore PMM interrupt enable register
        PMMRIE = PMMRIE_backup;
        //Lock PMM registers for write access
        PMMCTL0_H = 0x00;
        //return: voltage not set
        return false;
    }

    //Set also SVS highside to new level
    //Vcc is high enough for a Vcore increase
    SVSMHCTL |= (SVSHRVL0 * level);

    //Wait until SVM highside is settled
    while((PMMIFG & SVSMHDLYIFG) == 0)
    {
        ;
    }

    //Clear flag
    PMMIFG &= ~SVSMHDLYIFG;

    //Set VCore to new level
    PMMCTL0_L = PMMCOREV0 * level;

    //Set SVM, SVS low side to new level
    SVSMLCTL = SVMLE | (SVSMLRRL0 * level) |
               SVSLE | (SVSLRVL0 * level);

    //Wait until SVM, SVS low side is settled
    while((PMMIFG & SVSMLDLYIFG) == 0)
    {
        ;
    }

    //Clear flag
    PMMIFG &= ~SVSMLDLYIFG;
    //SVS, SVM core and high side are now set to protect for the new core level

    //Restore Low side settings
    //Clear all other bits _except_ level settings
    SVSMLCTL &= (SVSLRVL0 + SVSLRVL1 + SVSMLRRL0 +
                 SVSMLRRL1 + SVSMLRRL2
                 );

    //Clear level settings in the backup register,keep all other bits
    SVSMLCTL_backup &=
        ~(SVSLRVL0 + SVSLRVL1 + SVSMLRRL0 + SVSMLRRL1 + SVSMLRRL2);

    //Restore low-side SVS monitor settings
    SVSMLCTL |= SVSMLCTL_backup;

    //Restore High side settings
    //Clear all other bits except level settings
    SVSMHCTL &= (SVSHRVL0 + SVSHRVL1 +
                 SVSMHRRL0 + SVSMHRRL1 +
                 SVSMHRRL2
                 );

    //Clear level settings in the backup register,keep all other bits
    SVSMHCTL_backup &=
        ~(SVSHRVL0 + SVSHRVL1 + SVSMHRRL0 + SVSMHRRL1 + SVSMHRRL2);

    //Restore backup
    SVSMHCTL |= SVSMHCTL_backup;

    //Wait until high side, low side settled
    while(((PMMIFG & SVSMLDLYIFG) == 0) &&
          ((PMMIFG & SVSMHDLYIFG) == 0))
    {
        ;
    }

    //Clear all Flags
    PMMIFG &= ~(SVMHVLRIFG | SVMHIFG | SVSMHDLYIFG |
                SVMLVLRIFG | SVMLIFG | SVSMLDLYIFG
                );

    //Restore PMM interrupt enable register
    PMMRIE = PMMRIE_backup;

    //Lock PMM registers for write access
    PMMCTL0_H = 0x00;

    return true;
}

bool increaseVCoreToLevel2()
{
    uint8_t level = 3;//2;
    uint8_t actlevel;
    bool status = true;

    //Set Mask for Max. level
    level &= PMMCOREV_3;

    //Get actual VCore
    actlevel = PMMCTL0 & PMMCOREV_3;

    //step by step increase or decrease
    while((level != actlevel) && (status == true))
    {
        if(level > actlevel)
        {
            status = setVCoreUp(++actlevel);
        }
        else{
            status = setVCoreUp(--actlevel);
        }
    }

    return (status);
}

void SendUCA0Data(uint8_t val)
{
    //while (!(UCA0IFG & UCTXIFG));              // USCI_A0 TX buffer ready?
    UCA0TXBUF = val;
}
/**
 * main.c
 */
typedef enum SPI_ModeEnum{
    IDLE_MODE,
    SET_IT_MODE,
    TX_MODE,
} SPI_Mode;

uint8_t SlaveMode = IDLE_MODE;
uint8_t TxBuff[4096] = {0};
uint8_t *txptr;
uint8_t RXCounter = 0;  //To receive the integration time (2 bytes)
uint16_t TXCounter = 4096;
volatile uint16_t TXIndex = 0;
uint16_t integration_time = 2096;

uint8_t debug = 1;

int main(void)
{
	WDTCTL = WDTPW | WDTHOLD;	// stop watchdog timer
	
    increaseVCoreToLevel2();
    initClockTo16MHz();
    initGPIO();
    initSPI();

    //txptr = TxBuff;             //Init the txpointer to the correc position

    __bis_SR_register(GIE);
    while (1){
        if(SlaveMode == TX_MODE && TXIndex == 0){
            //SensorRead();
            TxBuff[0] = 27;
            TxBuff[1] = 28;
            TxBuff[2] = 29;
            TxBuff[3] = debug;
            TxBuff[4095] = 32;
            debug++;
            //UCA0TXBUF = *txptr++;
            //SendUCA0Data(TxBuff[TXIndex++]);
            UCA0TXBUF = TxBuff[TXIndex++];

        }
    }
	return 0;
}

//******************************************************************************
// SPI Interrupt ***************************************************************
//******************************************************************************



#if defined(__TI_COMPILER_VERSION__) || defined(__IAR_SYSTEMS_ICC__)
#pragma vector=USCI_A0_VECTOR
__interrupt void USCI_A0_ISR(void)
#elif defined(__GNUC__)
void __attribute__ ((interrupt(USCI_A0_VECTOR))) USCI_A0_ISR (void)
#else
#error Compiler not supported!
#endif
{
  uint8_t uca0_rx_val = 0;
  switch(__even_in_range(UCA0IV,4))
  {
    case 0:break;                             // Vector 0 - no interrupt
    case 2:                                   // Vector 2 -RX interrupt
        uca0_rx_val = UCA0RXBUF;
        switch (SlaveMode)
        {
              case (IDLE_MODE):
                  if (uca0_rx_val == IT_CMD) {
                      RXCounter = 0;
                      SlaveMode = SET_IT_MODE;
                      UCA0TXBUF = 99;
                  }
                  else if (uca0_rx_val == TX_CMD) {SlaveMode = TX_MODE;}
                  break;
              case (SET_IT_MODE):

                  integration_time |= uca0_rx_val<<(RXCounter*8);
                  RXCounter++;

                  if (RXCounter >= 2) {
                      SlaveMode = IDLE_MODE;
                  }
                  UCA0TXBUF = 99;

                  break;
              case (TX_MODE):
                  TXCounter--;
                  if(TXCounter<1){
                      UCA0TXBUF = 86;
                      //txptr = TxBuff;           //reset pointer
                      TXCounter = 4096;
                      TXIndex = 0;
                      SlaveMode = IDLE_MODE;
                      break;
                  }
                  if (TXIndex > 0){
                      //UCA0TXBUF = *txptr++;
                      //SendUCA0Data(TxBuff[TXIndex++]);
                      UCA0TXBUF = TxBuff[TXIndex++];
                  }
                  else {UCA0TXBUF = 11;}
                  break;
              default:
                  UCA0TXBUF = 77;
                  __no_operation();
                  break;
        }

        break;
    case 4:break;                             // Vector 4 - TXIFG
    default: break;
  }
}

//END OF THE CODE

Correct at 180KHz:

First byte twice at 500KHz:

More bytes repeated at 3MHz:

Thanks in advance.

MSP430FR6989: Keypad.h library for the MSP430FR6989

$
0
0

Part Number:MSP430FR6989

Is there a keypad.h library file for the MSP430FR6989? I have an Adafruit 4x3 keypad and the goal is to read input from the keypad to the LCD display to the micro controller using Code Composer Studio. However, we do not have a keypad.h file for the code. Is there a link where I can find the file?

MSP430FR2512: How to design a PCB so that proximity sensing reaches 5-10cm using 2032 power supply?

$
0
0

Part Number:MSP430FR2512

I tested or modified at least four versions of the PCB,It is found that if the external dc source is used, the power supply distance can be a little farther, and it is best to achieve about 5cm.

 

However, if cr2032 is used for power supply, the distance will be shortened. At present, the best distance is about 3cm and it is not stable.


MSP430FR5994: PMM_lockLPM5() function similar to PMM_unlockLPM5() function

$
0
0

Part Number:MSP430FR5994

Hi,

  In MSP430FR5994, I am enabling all GPIO (after doing necessary settings of OUTPUT or INPUT) using the function PMM_unlockLPM5(). Is there a corresponding function like PMM_lockLPM5() which will set all GPIO(s) back to their high impedance state? If not, is there a way of doing it?

Thanks

Regards

Soumyajit

MSP430FR5994: RTC value retention after WDT Reset or Reset by pulse on MCU RST pin

$
0
0

Part Number:MSP430FR5994

Hi,

  If power is continuously present to the MCU (MSP430FR5994), will a WDT reset or MCU reset by pulse on MCU RST pin corrupt the RTC value? Or will RTC run as usual retaining its value?

-

Thanks

-

Regards

Soumyajit

TIDM-1021: Water Proof touch design using Captivate solution

$
0
0

Part Number:TIDM-1021

Hello.

I would like to know following design detail.

My customer are going to make Water Proof touch sensor in horizontal position,so there is possibility that a large drop of water that covers multiple buttons is on the touch sensor for long time.

Under above condition,

 1.Is TIDM-1021 possible to avoid false detection by such a large drop of water ?

 2.Is TIDM-1021 possible to detect touch functionally when there is such a large drop of water?

 3.For running demo to customer, are there any way to get TIDM-1021 demo board?

Regards,

U-SK

MSP430FR2433: DCO without FLL operation

$
0
0

Part Number:MSP430FR2433

Hi, I'm trying to use DCO without FLL operation. Is is possbile without problem over temperature?

The DCO FLL lock time of MSP430FR2433 is described as 280ms at the datasheet.
It is too late for our application and 2ms is desired.

In order to solve the issue, is it possbile for us to do the following usage?

1) At a factory, CSCTLO register value is measured using FLL operation under 25 °C

2) Then, the measured value is stored to the FeRAM.

3) When the MSP430FR2433 is powered on, it reads the value for CSCTL0 from the FeRAM
   and then the value is set to the CSCTL0 register.

4) After setting the CSCTL0 value, we force MSP430FR2433 not to use FLL.

5) The product may be used from -10°C to +60°C.

I have another question.
Without FLL operation, Could we think that the DCO frequency torelance is
same as REFO absolute calibrated tolerance( –40°C to 85°C 1.8 V to 3.6 V) –3.5% +3.5%?

Compiler/MSP430G2553: LCD display with MSP430G2553 for IAR Embedded Workbench

$
0
0

Part Number:MSP430G2553

Tool/software: TI C/C++ Compiler

Hi,

I am trying to display on the LCD the battery voltages & currents by reading the ADC values from MSP430.

By using Energia IDE & Launchpad i am able to display on the LCD and its working fine.

But i need to use IAR embedded workbench to display these values ,any example code and libraries for the LCD would help.

I am using JHD162A LCD , any compatible libraries & drivers for it also helps.

Regards,

Phanendra

MSP430FR2433: external reference for ADC

$
0
0

Part Number:MSP430FR2433

Hi, 

does MSP430FR2433 support an external ADC voltage input as reference?  There is an EXTREFEN bit in PMM register, but it seems for controlling output internal 1.2v voltage to Vref+ pin.

Thanks,

Falong

Linux/MSP430AFE232: as above

$
0
0

Part Number:MSP430AFE232

Tool/software: Linux

hi everyone I am working on wireless sensor network and using xm1000 kit by AdvanticSys, which also have msp430 microcontroller. I want to know that can we program xm1000 through Code Composer Studio (other than tinyOs and Contiki)? 


MSP-FET: How to set mode setting SWD/JTAG in Uniflash

MSP430FR2433: BSL & JTAG Lock - Lunchpad & Custom PCB

$
0
0

Part Number:MSP430FR2433

Hello, 

My target is to lock both BSL and JTAG on MSP430FR2433, with a mass erase on wrong BSL password. That both on launchpad for testing and a custom PCB. 

  1. Is the correct approach to write over the following addresses in the FRAM in the beginning of the application code? If so…can someone provide an example please? I couldn’t find anything yet and I got confused a bit by the differences in each IC/documentation…since I have tried but I didn’t have a way to confirm yet…

BSL Password -> 0xFFE0 to 0xFFFF (top 16 words in the BSL interrupt vector table)

BSL Signature 2 -> 0FF86h (e.g. write BC87h)

BSL Signature 1 -> 0FF84h (e.g. write BC87h)

JTAG Signature 2 - 0FF82h     (e.g. write BC87h)

JTAG Signature 1 - 0FF80h (e.g. write BC87h)

  1. Or will both of this be possible through the BSL with? -> https://www.olimex.com/Products/MSP430/BSL/MSP430-BSL/
  2. Will I be able to confirm both BSL & JTAG lock as per SLAASE59D & 550S  with https://www.olimex.com/Products/MSP430/BSL/MSP430-BSL/  and  http://www.ti.com/lit/ug/slau573b/slau573b.pdf ? (CCS cannot confirm JTAG on this MSP i think)
  3. Should I be looking at the IPE option for the whole program or is this a bad approach/overkill and should only be used for only sections of a program?

Thanks,

Con

CCS/RF430FRL152HEVM: RF430FRL152HEVM,MSP-EXP430G2ET: Have problem to make NFC(near field communication) and Supply to port power simultaneously

$
0
0

Part Number:RF430FRL152HEVM

Tool/software: Code Composer Studio

hello,

I am currently trying to use msp-exp430g2et as master and rf430frl152hevm as slave to cross drive two LEDs over NFC communications.

i opened the port in ccs and debugged using a timer for interrupt coding.

debugging succeeded, but there was a problem.

when connecting usb directly to rf430FRL152HEVM two LEDS worked well as i wanted. but when using NFC communication, the LED did not light up.

I checked with the STEP OVER function and found that during the NFC communication, it did not proceed to the interrupt timer i coded.

if there is any solution, or if there is an example of crossing the LED with NFC communication. let me know. Thanks

-SINCERELY-

CCS/MSP430F2274: i2c master receiver program does not receive the rx buffer data from master program code

$
0
0

Part Number:MSP430F2274

Tool/software: Code Composer Studio

hi friends,

i am  connected light sensor and msp430f2274  with i2c interface.

i write program code for I2C master receiver program in CCSV5.1

But the transmiter the data and store in data in TXbuffer but it doesnot send at  rxBUFFER.

What is the problem?

BCSCTL1 = CALBC1_16MHZ;                             // Set DCO to calibrated 16MHz
    DCOCTL = CALDCO_16MHZ;
    BCSCTL2 |= DIVS_3;                                  // SMCLK to 2 MHz

PORT_I2C_SEL |= BIT2 | BIT1;                        // Set I/O pins 1 and 2 for port 3 to be for the  //   I2C peripheral
    //PORT_I2C_DIR |= BIT0;                               // Set port 3 pin 0 as output and set high.   PORT_I2C_OUT |= BIT0;
    UCB0CTL1 |= UCSWRST;                                // Put state machine in reset
    UCB0CTL0 |= UCMST + UCSYNC + UCMODE_3;              // I2C mode, master, synchronous
    UCB0CTL1 = UCSSEL_2 + UCSWRST;                               // SMCLK as clock source
    UCB0BR0 = 3;                                        // 2MHz/5 = 400kHz
    UCB0BR1 = 0;
    UCB0I2CSA = 0x39;                                   // Slave Address is 1Eh
    UCB0CTL1 &= ~UCSWRST;                               // Start I2C state machine
    IE2|=UCB0RXIE;                                         //ENABLE Rx interrupt

unsigned char i2c_read(unsigned char regAddress)
{
unsigned char Result;
UCB0CTL1 |= UCTR + UCTXSTT;                         // I2C TX, start condition
//while (!(IRQ_REG & TX_IFG));                        // Wait for slave address transmit to complete
TX_BUFFER = regAddress;                                // Load TX buffer with register address
//while (!(IRQ_REG & TX_IFG));                        // Wait for transmit to complete
IRQ_REG &= ~TX_IFG;                                 // Clear USCI_B0 TX int flag
// Send restart with transmit/receive bit NOT set
UCB0CTL1 &= ~UCTR;                                  // Toggle transmitter bit
UCB0CTL1 |= UCTXSTT;                                // I2C start condition
//while(UCB0CTL1 & UCTXSTT);                          // Wait for start to complete
UCB0CTL1 |= UCTXSTP;                                // I2C stop condition
//while (!(IRQ_REG & RX_IFG));                        // Wait for receive buffer to fill
Result = RX_BUFFER;                                 // Fill receive data buffer with received byte
//while (UCB0CTL1 & UCTXSTP);                         // Wait for stop condition to complete
IRQ_REG &= ~RX_IFG;                                 // Clear USCI_B0 RX int flag  return Result;
}

is it right code for read the data from receiver to send the transmitter then the store in rxbuffer.

can u any body send the program for received the data from slave device 

i2c adress= 0x39;

only two bytes receiver from slave device.

so please me as possible soon..

CCS/MSP430G2553: MSP430 with humidity sensor interface using I2C communication

$
0
0

Part Number:MSP430G2553

Tool/software: Code Composer Studio

Hello,

I have started a new task in I2C communication. I have interface MSP430 with humidity sensor using I2C communication so any example code for this ? suggest me.

Viewing all 21951 articles
Browse latest View live


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