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

MSP430FR5994: What is the max frequency of a Timer_A interrupt containing GPIO writes?

$
0
0
Part Number: MSP430FR5994

I am attempting to Bit-Bash a UART communication (the built in module doesn't work for my application) and am having problems achieving a baud rate of 250kbps.

My MSP430 is setup to run at 16MHz and the Timer is setup as follows:

/* Timer A4 - Tx */
TA4CTL &= ~0x3F7;
TA4CTL |= TBSSEL__SMCLK;  			/* Choose SMCLK as clock source */
TA4CTL |= ID__1; 					/* Clock input divider - 1 */
TA4EX0 |= TBIDEX__1; 				/* Clock input divider expansion - 1 */
TA4CTL |= MC__UP; 				    /* Mode select - Up Mode */
TA4CCR0 = 0U; 						/* Stop the Timer */
TA4CTL |= TBCLR; 					/* Timer_B clear */

When I want to start the timer I use the following to get the Timer to trigger every 4us:

/* Start transmission */
TA4CCTL0 |= CCIE ; 						/* Timer_A int enable */
TA4CCR0 = 64U;

When I only include a simple GPIO toggle in the interrupt, the output frequency can keep to 4us, however if I try to add more complexity into the interrupt, the fastest it can go is 5.5us, often as high as 6.5-9us. 

I would like to implement the following interrupt:

main(void)
{
  while(1)
  {
    while(uart_ctl.bit_index != uart_ctl.frame_bit_count);
    uart_ctl.bit_index = 0U;
  }
}

#pragma vector = TIMER4_A0_VECTOR
__interrupt void Uart_tx_timer_isr(void)
{
  P2OUT = uart_ctl.tx_buffer[uart_ctl.bit_index];   /* Set state of Port 2 to the values in transmit buffer */

  uart_ctl.bit_index += 1U; 				        /* Increment bit index */
}

where each element of uart_ctl.tx_buffer contains the state of each pin on Port 2, where BIT0 (Tx pin) changes depending on each bit in the message. Both the uart.ctl struct, and the interrupt, are in RAM. I am using Compiler version v21.6.9.

Is it actually possible to run the interrupt every 4us while doing this operation? To me it doesn't seems terribly complex and should easily be able to manage it in 64 clock cycles, am I wrong in this assumption? If it is possible, are there any registers I may have not set up, or set up incorrectly?

Thanks in advance,

Joe


MSP430FR2355: Very basic question on ISR using LPM3_EXIT??

$
0
0
Part Number: MSP430FR2355

I have a basic c question as I am seeing some strange thing.

I would like to know when in an ISR and you come upon the command LPM3_EXIT, does the code immediately act on that command and exit the ISR and wake OR does the code linearly go thru the ISR until the end AND then when it reaches the end of the ISR does it recall the LPM3_EXIT statement, exit and wake??

#pragma vector=PORT1_VECTOR
__interrupt void indicatorButtons(void)
{
    p1flags = (P1IFG & 0xFE);
    switch (__even_in_range(P1IV, 16))
    {
        case 2:
            ISR.reset = T;
            LPM3_EXIT;
        break;

        case 4: //P1.1
            currentSwState ^= SW1;
            break;
        case 6: //P1.2
            currentSwState ^= SW2;
            break;
        case 8: //P1.3
            currentSwState ^= SW3;
            break;
        case 10: //P1.4
            currentSwState ^= SW4;
            break;
        case 12: //P1.5
            P1IES ^= BIT5;
            break;
        case 14: //P1.6
            P1IES ^= BIT6;
            break;
        case 16: //P1.7
            currentSwState |= ALL;
            break;
        default:
            break;
    }
    debounce();
    if ((ISR.joinSwFlag) || (P1IES & (BIT6|BIT5)))
    {
        TB1CCR1 = TB1R + TENTHSEC;
        TB1CCTL1 &= ~CCIFG;
        TB1CCTL1 |= CCIE;
    }

    if (!ISR.joinSwFlag)
    {
        //reset 10 sec counter
        count = 0;
        TB2R = 0;
        TB2CCTL0 &= ~CCIE;
        TB2CCTL0 |= CCIE;
    }

    P1IE &= ~0xFE;
    pwmRemote(currentSwState, remote);
}

MSP430F5659IPZ vs MSP430F5659IPZ and IPZR

$
0
0

Hi All, 

Because of shortage microcontrollers for MSP430F5359IZQWT BGA-113 we want to understand if it is possible to use  MSP430F5659IPZ and IPZR instead without changing layout of PCB.

All these microcontrollers showing under the same data sheet. 

From the datasheet it looks like it could be a close match with minimal or no layout changes. Please correct me if I'm wrong. 

It differs from the MSP430F5359IPZ because it has a USB (that can be disabled) and if disabled the 2K SRAM for the USB can be used for anything else. So, effectively it has the same 66KB SRAM as the part we are using.

Can you please advise if there are some big difference between them. 

 This is minimum requirements for our devices:

Core arch: CPUXV2

Freq:: 20MHz

Flash:512kB

SRAM: 66kB

PIO: 74

I2C: 3

ADC: 10 BIT

Thank you !!!

MSP430F5310: MSP430F5310 input pin maximum voltage

$
0
0
Part Number: MSP430F5310

We are using MSP430F5310 part for one of our project. The product is battery powered and 12V adaptor is used for charging. The MSP430 powered using LDO connected at the common point of battery & 12V so that it gets 3.3V if battery or 12 V is present. We have to sense the 12V by MSP430. Can we connect 12V using resistor divider to any of the analog pin of the MSP430. Whether the pin or IC will damage since the 12V will comes before the MSP430 power goes up.

MSP430F5659IPZ and IPZR

$
0
0

I currently have board designed with MSP430F5359IPZ and looking to populate it with MSP430F5659IPZ. Only thing is PUR pin is floating in current design. Will I have any issues with device working during power cycles or any other functions like programming? In datasheet they recommend 1M resistor to ground  but I would like to know the impact of leaving this pin floating.

MSP430F5342: Verify fail with MSP Flasher

$
0
0
Part Number: MSP430F5342

Hello,

I try to program the MCU with MSPflasher v1.3.20 but when I want to check the programming, the probe fails

MSPFlasher documentation (SLAU654E-Nov 2015) say error 60 = "Could not terminate EEM polling thread". But I don't know what I need to do to not get an error.

Did you have any idea ?

Thanks for your help

MSP430FR2355: I2C issuing a restart?

$
0
0
Part Number: MSP430FR2355

When I issue an I2C transmit start my code automatically sends out the address and a write and jumps into the TXIE0 for the first byte.  Can someone tell me when I issue an I2C restart will I jump into the TXIE0 after the address and a read is sent out over the bus OR will I jump into RXIE0?

MSP430FR2355: XT1 High Frequency crystal selection #2

$
0
0
Part Number: MSP430FR2355

Hi,

I asked similar question before for 12MHz crystal.
https://e2e.ti.com/support/microcontrollers/msp-low-power-microcontrollers-group/msp430/f/msp-low-power-microcontroller-forum/1117924/msp430fr2355-xt1-high-frequency-crystal-selection

Now customer is asking for 24MHz crystal.
Frequency :24MHz
Freq. Tolerance : +/- 15ppm
Temp. Tolerance : +/- 22ppm
Aging : +/- 5ppm/yr

Based on the previous answer, I think this 24MHz crystal is ok for FR2355, but please double check it.

Thanks and regards,
Koichiro Tashiro


MSP430FR5994: EnergyTrace doesn't count time util the end of the main function

$
0
0
Part Number: MSP430FR5994
Other Parts Discussed in Thread: ENERGYTRACE

Code Composer Studio Version: 8.3.1

After I started the Debug session, I clicked the Resume to continue the program.

But EnergyTrace doesn't count time util entering the abort function.

Just like the following screen snippet, Time kept 0, and Energy fluctuated between 1 and 5 mJ.

After finishing the main function, EnergyTrace finally start to count Time.

But the Energy plot is strange, there are two blue lines in it!

However, if I click Free Run to continue my program, it looks fine.

The following is my EnergyTrace setting:

I summary my questions below:

1. Why doesn't EnergyTrace count time util finishing my main function? How to fix it?

2. Why are there two blue lines in my Energy plot?

Thanks for your help.

MSP430FR2355: I2C UCSTPIFG vs UCTXSTP?

$
0
0
Part Number: MSP430FR2355

Can someone tell me why in the i2c module you would use one method over the other (UCSTPIFG vs UCTXSTP) to generate a stop flag when not in auto mode?

MSP430FR2355: I2C receive can't get working??

$
0
0
Part Number: MSP430FR2355

Below are two copies of my i2c ISR code.  The first copy is transmit only and seems to work very well (I maybe have seen a lockup (ie data line being pulled low and never released once or twice).  The second copy is an attempt to add receive to it.  The receive only allows one register read, the write allows many writes.  This second block of code is constantly crashing.  Very frequently I get only the address clocked out and a NACK from the LCD slave....The slave has power and I have 4.75kohm pullups on the SDA, SCL lines.  The master is an MSP430FR2355 Development board.  Questions:

1.  Can someone tell me if I am handling the clock low and NACK appropriately by just issuing an I2C Stop?

2.  Can someone tell me if I am doing anything wrong?

ISR with tx only: (notice I do not handle NACK here although I do handle clock low)

    switch(__even_in_range(UCB0IV, USCI_I2C_UCBIT9IFG))
    {
      case USCI_NONE: break;
      case USCI_I2C_UCALIFG: break;
      case USCI_I2C_UCNACKIFG: break;
      case USCI_I2C_UCSTTIFG: break;
      case USCI_I2C_UCSTPIFG:
          ISR.I2CComplete = T;
          LPM3_EXIT;
          break;
      case USCI_I2C_UCRXIFG3: break;
      case USCI_I2C_UCTXIFG3: break;
      case USCI_I2C_UCRXIFG2: break;
      case USCI_I2C_UCTXIFG2: break;
      case USCI_I2C_UCRXIFG1: break;
      case USCI_I2C_UCTXIFG1: break;
      case USCI_I2C_UCRXIFG0:
        break;
      case USCI_I2C_UCTXIFG0:
          applicationI2C.pSysCommsB->UCBxTXBUF = *pI2CStream;
          pI2CStream++;
          break;
      case USCI_I2C_UCBCNTIFG: break;
      case USCI_I2C_UCCLTOIFG:
          applicationI2C.pSysCommsB->UCBxIFG |= UCSTPIFG;
          break;
      case USCI_I2C_UCBIT9IFG: break;
      default: break;
    }

ISR with rcv functionality:

    switch(__even_in_range(UCB0IV, USCI_I2C_UCBIT9IFG))
    {
      case USCI_NONE: break;
      case USCI_I2C_UCALIFG: break;
      case USCI_I2C_UCNACKIFG:
          applicationI2C.pSysCommsB->UCBxIFG |= UCSTPIFG;
          break;
      case USCI_I2C_UCSTTIFG: break;
      case USCI_I2C_UCSTPIFG:
          applicationUART.pSysCommsA->UCAxIE |= UCTXIE;
          ISR.I2CComplete = T;
          LPM3_EXIT;
          break;
      case USCI_I2C_UCRXIFG3: break;
      case USCI_I2C_UCTXIFG3: break;
      case USCI_I2C_UCRXIFG2: break;
      case USCI_I2C_UCTXIFG2: break;
      case USCI_I2C_UCRXIFG1: break;
      case USCI_I2C_UCTXIFG1: break;
      case USCI_I2C_UCRXIFG0:
          applicationUART.pSysCommsA->UCAxTXBUF = applicationI2C.pSysCommsB->UCBxRXBUF;
          applicationI2C.pSysCommsB->UCBxIE &= ~UCRXIE0;
          applicationI2C.pSysCommsB->UCBxIFG |= UCSTPIFG;
          break;
      case USCI_I2C_UCTXIFG0:
          if (applicationI2C.pSysCommsB->UCBxCTLW[0] & UCTR)
          {
              applicationI2C.pSysCommsB->UCBxTXBUF = *pI2CStream;
              pI2CStream++;
              /*
               * UART ASCII --> 2 chars
               * a read will be two UART
               * chars representing address
               */
              if (mssgLength < 3)
              {
                  applicationI2C.pSysCommsB->UCBxCTLW[0] &= ~UCTR;
                  applicationI2C.pSysCommsB->UCBxCTLW[0] |= UCTXSTT;
                  applicationI2C.pSysCommsB->UCBxIE &= ~UCTXIE;
              }
          //}
          break;
      case USCI_I2C_UCBCNTIFG: break;
      case USCI_I2C_UCCLTOIFG:
          applicationI2C.pSysCommsB->UCBxIFG |= UCSTPIFG;
          break;
      case USCI_I2C_UCBIT9IFG: break;
      default: break;
    }

MSP430FR5969: BSL mass erase not working.

$
0
0
Part Number: MSP430FR5969

Hardware Setup : I'm using the MSP430FR 5969 launchpad (https://www.ti.com/lit/ug/slau535b/slau535b.pdf?ts=1658258840470&ref_url=https%253A%252F%252Fwww.ti.com%252Ftool%252FMSP-EXP430FR5969). I have removed the RXD and TXD jumpers on J13 and have connected them to a serial port with appropriate voltage levels to access UARTA0. I have a second serial port connected the P2.5 and P2.5 pin on J4 to access UARTA1 for my "monitor" software.

Software setup: I wrote a program in Code Composer that monitors the UARTA1 input and will branch into the BSL using the code from SLAU319AE

__disable_interrupt();// disable interrupts
((void ( * )())0x1000)();// jump to BSL

The software connected to UARTA0 to communicate with the BSL is written in C and is running on Ubuntu.

The system appears to be communicating with the BSL becaue when I branch to the BSL from the monitor and send a password protected command from the Liinux code I get a response that matches what the FRAM BSL document (SLAU550AA) says I should expect. 

For example: I start the BSL and send the protected command "TX BSL Version", 0x19.

st29142@574814-MITLL-VM-Ubuntu-2204:~/eclipse-workspace/MSP430_BSL/build/default$ ./MSP430_BSL 19
BSL file loader built 10:59:16 Jul 19 2022
Opening port /dev/ttyS1
port open argc = 2
19 0x19
CRC length = 1
0x19
0x62e8
i+4 = 6 0x80 0x01 0x00 0x19 0xe8 0x62
wrote 6 characters
received 8 characters
received 0x00
received 0x80
received 0x02
received 0x00
received 0x3b
received 0x04
received 0xe4
received 0x84

The data packet matches the example in section 4.1.5.7 and the response indicates the BSL is locked (the 0x04 in byte 6). This as expected and confirms I have communications with the BSL and it is functioning.

My problem: When I command the mass erase, I do not receive the BSL response that SLAU550AA indicates in 4.1.5.3 I should get. In addition, the monitor software I loaded with Code Composer should have been erased, but when I reset the launchpad with the hardware reset (button S3) the monitor starts.

$ ./MSP430_BSL 15
BSL file loader built 10:59:16 Jul 19 2022
Opening port /dev/ttyS1
port open argc = 2
15 0x15
CRC length = 1
0x15
0xa364
i+4 = 6 0x80 0x01 0x00 0x15 0x64 0xa3
wrote 6 characters
received 0 characters

Is there some difference between starting from software and starting with the Test signal on a reset that is keeping this from working?

Is there different BSL loaded into the MSP430FR5969 on the launchpad?

Is there some hidden hardware in the scratchpad that is restoring my monitor program on a reset?

Any suggestions would be greatly appreciated.

Thanks in advance.

 

MSP430FR4133: I have TI parts that are drawing way too much current. Might I have some that are faulty parts or Chinese Knock Offs.

$
0
0
Part Number: MSP430FR4133

I have a reel of MSP430FR4133IG56  56 pin controllers.  They are all drawing about 0.3 ma  while the same part I ordered directly from TI website is drawing about 7 uA.  How do I figure out if I have a reel of faulty parts or Chinese Knock offs?

Garret

MSP430FR5969: I2C with HDC2080 stuck in an infinite loop

$
0
0
Part Number: MSP430FR5969
Other Parts Discussed in Thread: HDC2080

I'm trying to connect a board that uses the MSP430FR5969 (the WISP 5.1) with a HDC2080 temperature/humidity sensor through I2C, using the driverlib HAL, based on this example. I'm using a 2k ohm pull-up, if that plays a part. The sensor was confirmed working fine with an Arduino, but now I wanted to replicate the functionality in the MSP.

Here's a code snippet I'm currently using (other unrelated parts omitted for brevity. If it helps, this is built on top of the WISP firmware in CCS 11):

#define SENSOR_ADDRESS 0x40             // HDC2080 address
#define SENSOR_CONFIG_REGISTER 0x0F     // HDC2080 configuration register

void initI2C(){
        WDT_A_hold(WDT_A_BASE);

        //Set DCO frequency to 1MHz
        CS_setDCOFreq(CS_DCORSEL_0,CS_DCOFSEL_0);
        //Set ACLK = VLO with frequency divider of 1
        CS_initClockSignal(CS_ACLK,CS_VLOCLK_SELECT,CS_CLOCK_DIVIDER_1);
        //Set SMCLK = DCO with frequency divider of 1
        CS_initClockSignal(CS_SMCLK,CS_DCOCLK_SELECT,CS_CLOCK_DIVIDER_1);
        //Set MCLK = DCO with frequency divider of 1
        CS_initClockSignal(CS_MCLK,CS_DCOCLK_SELECT,CS_CLOCK_DIVIDER_1);

        // Configure Pins for I2C
        //Set P1.6 and P1.7 as Secondary Module Function Input.
        /*

        * Select Port 1
        * Set Pin 6, 7 to input Secondary Module Function, (UCB0SIMO/UCB0SDA, UCB0SOMI/UCB0SCL).
        */
        GPIO_setAsPeripheralModuleFunctionInputPin(
            GPIO_PORT_P1,
            GPIO_PIN6 + GPIO_PIN7,
            GPIO_SECONDARY_MODULE_FUNCTION
        );

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

        //Initialize Master
        EUSCI_B_I2C_initMasterParam param = {0};
        param.selectClockSource = EUSCI_B_I2C_CLOCKSOURCE_SMCLK;
        param.i2cClk = CS_getSMCLK();
        param.dataRate = EUSCI_B_I2C_SET_DATA_RATE_400KBPS;
        param.byteCounterThreshold = 1;
        param.autoSTOPGeneration = EUSCI_B_I2C_NO_AUTO_STOP;
        EUSCI_B_I2C_initMaster(EUSCI_B0_BASE, &param);

        //Specify slave address
        EUSCI_B_I2C_setSlaveAddress(EUSCI_B0_BASE, SENSOR_ADDRESS);

        //Set in transmit mode
        EUSCI_B_I2C_setMode(EUSCI_B0_BASE, EUSCI_B_I2C_TRANSMIT_MODE);

        // Set timeout to prevent infinite loops
        EUSCI_B_I2C_setTimeout(EUSCI_B0_BASE, 1000);

        //Enable I2C Module to start operations
        EUSCI_B_I2C_enable(EUSCI_B0_BASE);
}

uint8_t readI2CRegister(uint8_t registerAddress){

    // Send single byte as address
    EUSCI_B_I2C_masterSendSingleByte(EUSCI_B0_BASE, registerAddress);

    // Delay until transmission completes
    while (EUSCI_B_I2C_isBusBusy(EUSCI_B0_BASE));

    // Switch to read mode
    EUSCI_B_I2C_setMode(SENSOR_ADDRESS, EUSCI_B_I2C_RECEIVE_MODE);

    // Receive start
    EUSCI_B_I2C_masterReceiveStart(SENSOR_ADDRESS);

    // Read data from register (and then send STOP)
    uint8_t data = EUSCI_B_I2C_masterReceiveSingle(SENSOR_ADDRESS);

    // Return data
    return data;
}

void writeI2CRegister(uint8_t registerAddress, uint8_t data){

    // Go to transmit mode
    EUSCI_B_I2C_setMode(SENSOR_ADDRESS, EUSCI_B_I2C_TRANSMIT_MODE);

    // Send single byte as address
    EUSCI_B_I2C_masterSendSingleByte(EUSCI_B0_BASE, registerAddress);

    // Delay until transmission completes
    while (EUSCI_B_I2C_isBusBusy(EUSCI_B0_BASE));

    // Send data
    EUSCI_B_I2C_masterSendSingleByte(EUSCI_B0_BASE, data);

    // Delay until transmission completes
    while (EUSCI_B_I2C_isBusBusy(EUSCI_B0_BASE));

}

void main(void) {

    ...

    // Init I2C
    initI2C();
    
    // Enable measurements on the HDC2080 with mostly default settings
    writeI2CRegister(SENSOR_CONFIG_REGISTER, 0x01);
    
    uint8_t temp1;
    while(true){
        ...
        temp1 = readI2CRegister(0x00);
        ...
    }
}

When this is run, it looks like the code is getting stuck in "EUSCI_B_I2C_masterSendSingleByte" (in driverlib's eusci_b_i2c.c). More specifically, it's looping in here:

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

How can I further debug this problem?

MSP430FR2355: Power consumption when MCLK is driven at low frequency in Active Mode

$
0
0
Part Number: MSP430FR2355

Hi experts,

Is there any way to reduce power consumption even more than the following under the condition of Active mode?

[Condition]

  • Measured by Energy Trace using MSP-EXPFR2355 (in Free Run).
  • Active mode, 32.768KHz input from external crystal in MCLK.
  • All other peripherals are not used, and all GPIO pins are in the output direction and output Low.
  • Execute a while loop in the main function
  • VCC = 3.3V
  • No significant difference in results when using VLO or REFO
  • No difference even if SMCLKOFF=1, SMCLKREQEN=0

  

#include <msp430.h>
/**
 * main.c
 */
int main(void)
{
	WDTCTL = WDTPW | WDTHOLD;	// stop watchdog timer

    P2SEL1 |= BIT6 + BIT7;                  // P2.0: XOUT; P2.1: XI1

    CSCTL4 = SELMS__XT1CLK;
    CSCTL5 = SMCLKOFF_1;
    CSCTL8 &= ~(SMCLKREQEN_1);

    //  CSCTL4 = SELMS__REFOCLK;
    //  CSCTL5 = DIVM__128;

    P1OUT = 0x00;    P1DIR = 0xff;
    P2OUT = 0x00;    P2DIR = 0xff;
    P3OUT = 0x00;    P3DIR = 0xff;
    P4OUT = 0x00;    P4DIR = 0xff;
    P5OUT = 0x00;    P5DIR = 0xff;
    P6OUT = 0x00;    P6DIR = 0xff;

    PM5CTL0 &= ~LOCKLPM5;

    do
    {
        CSCTL7 &= ~(XT1OFFG | DCOFFG);      // Clear XT1 and DCO fault flag
        SFRIFG1 &= ~OFIFG;
    }while (SFRIFG1 & OFIFG);               // Test oscillator fault flag

	while(1){}

	return 0;
}

I understand that it is not appropriate to run MCLK at low frequency because MSP430 has several LPMs. I would like to check if it is possible to lower the power consumption when MCLK is driven at low frequency (below 32.678kHz) in Active Mode.

Best regards,
O.H


MSP430G2855: No footprint or dimensions available for RHA 40 pin

$
0
0
Part Number: MSP430G2855

The data sheet (SLAS800 –MARCH 2013) and package drawing on in the TI Packaging site (4225870/A, or maybe mpqf135d) are both missing the package dimensioned drawing and footprint.

MSP430FR2433: uniflash CLI target is halted after flashing

$
0
0
Part Number: MSP430FR2433
Other Parts Discussed in Thread: UNIFLASH

Hello All,

When I flash the MSP via the UniFlash GUI the target is running when the process completes. When I flash via the CLI ( created by the UniFlash ) the target seems to be halted.

I did try to add Reset operation ( both hard and soft ) but this didn't do the trick. What should I do to make the CLI act the same way as the GUI ? 

Thanks !

MSP430FR2355: Why does enabling UCRXIE(SPI) cause TX packet loss?

$
0
0
Part Number: MSP430FR2355

My code is fairly straightforward - to send out a packet of information consisted of four hex {0x01, 0x02, 0x03, 0x04} through SPI.  Everything works fine, until I add exactly one extra line of code that enables UCRXIE interrupt before entering the main loop.  

Before enabling UCRXIE, the data line transmits {0x01, 0x02, 0x03, 0x04}.  After enabling UCRXIE, the data line consistently transmits {0x01, 0x02, 0x04} - one hex short and for whatever reason it's always the 0x03that has gone missing.  I can't implement the interrupt functions for RX until I can resolve the issue with this packet loss -- eventually I'll have one EUSCI_A0_VECTOR to handle both UCTXIE and UCRXIE interrupt by checking which flags UCTXIFG and UCRXIFG get set, and my receiving RX packets depends on my TX sending packets on the SPI line.

Here I attached a screenshot and the code.

#include <msp430.h> 

char packet[] =
{
    0x01, 0x02, 0x03, 0x04      // packets
};

unsigned int position;

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

    UCA0CTLW0 |= UCSWRST;       // put eUSCI_A0 into SW reset

    UCA0CTLW0 |= UCSSEL__SMCLK; // choose 1MHz SMCLK as BRCLK
    UCA0BRW = 10;               // 1MHz divide by 10 = 100kHz

    UCA0CTLW0 |= UCSYNC;        // set bit to SPI mode
    UCA0CTLW0 |= UCMST;         // set bit to SPI master mode
    UCA0CTLW0 |= UCMSB_1;       // UCMSB_0=LSB; UCMSB_1=MSB
    UCA0CTLW0 |= UCMODE1;       // 4-wire STE LOW (10b)
    UCA0CTLW0 &= ~UCMODE0;      // ..
    UCA0CTLW0 |= UCSTEM;        // enable STE output pin

    P1SEL1 &= ~BIT5;            // P1.5 (UCA0SCLK)
    P1SEL0 |= BIT5;             // P1.5 ..
    P1SEL1 &= ~BIT7;            // P1.7 (UCA0SIMO)
    P1SEL0 |= BIT7;             // P1.7 ..
    P1SEL1 &= ~BIT6;            // P1.6 (UCA0SOMI)
    P1SEL0 |= BIT6;             // P1.6 ..
    P1SEL1 &= ~BIT4;            // P1.4 (STE)
    P1SEL0 |= BIT4;             // P1.4 ..

    P4DIR &= ~BIT1;             // P4.1 (SW1) clear as input
    P4REN |= BIT1;              // P4.1 (SW1) enable pull-up/down resistance
    P4OUT |= BIT1;              // P4.1 (SW1) pull-up
    P4IES |= BIT1;              // P4.1 (SW) interrupt edge select: high-to-low transition

    PM5CTL0 &= ~LOCKLPM5;       // get out of LPM
    UCA0CTLW0 &= ~UCSWRST;      // get out of SW reset

    P4IFG &= ~BIT1;             // P4.1 (SW1) clear IFG
    P4IE |= BIT1;               // P4.1 (SW1) enable IRQ

    UCA0IFG &= ~UCTXIFG;        // clear SPI Tx IFG
    UCA0IFG &= ~UCRXIFG;        // clear SPI Rx IFG
    UCA0IE |= UCTXIE;           // enable SPI TX IRQ
    UCA0IE |= UCRXIE;           // enable SPI RX IRQ

    __enable_interrupt();

    while(1)
    {
        // do nothing
    }

    return 0;
}

#pragma vector = PORT4_VECTOR
__interrupt void ISR_Port4_S1(void)
{
    position = 0;
    UCA0TXBUF = packet[position];
    P4IFG &= ~BIT1;
}

#pragma vector = EUSCI_A0_VECTOR
__interrupt void ISR_EUSCI_A0(void)
{
    position++;

    if(position < sizeof(packet))
    {
        UCA0TXBUF = packet[position];
    }
    else
    {
        UCA0IFG &= ~UCTXIFG;
    }
}

EVM430-FR6047: Automatic gain control

$
0
0
Part Number: EVM430-FR6047

To the person in charge

Please tell us about "Automatic gain control".
I found it in the reference guide, but I don't know what kind of function it is.

In what kind of cases is this function used?
Please let us know if you have any documents that can give us more details.

MSP430F6638: PortU pins function as outputs sample code

$
0
0
Part Number: MSP430F6638

Hey,

 

Do anybody have complete sample code or link to sample code showing how to enable PU.0 and PU.1 as Output pins and toggle them High-Low.

I am aware of section 42.2.1.3 Port U Control in the MSP430x6xx Family Users Guide, but it’s not working for me.

My IAR compiler doesn’t even let me work with PUSEL, but send the following message when trying to run it:

Error[Pe137]: expression must be a modifiable lvalue

Any hint or help is highly appreciated.

Viewing all 22188 articles
Browse latest View live