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

msp430fr2633: Capacitive soil moisture sensing with msp430fr2633

$
0
0

Part Number:msp430fr2633

Dear,

my question is simple. Do you think it is possible to measure soil moisture with msp430fr2633?

I have done some capacitive designs for HID but this is a different thing :)

My idea would be to baseline a sensor with the value obtained when in dry soil and then measure and compare.

Do you think this is feasible? Self-capacitive or mutual measuring? :)

Please let me know your opinions!

Have a really nice day!


Compiler/MSP430F5529: MSP dsplib confusion!

$
0
0

Part Number:MSP430F5529

Tool/software: TI C/C++ Compiler

First post on here so go easy on me!

I'm trying to get my head around the fixed point FFT code in MSP dsplib, in particular msp_fft_fixed_q15.

The example code initialises the input array using the msp_sinusoid_q15 utility, which presumably puts q15 results into the input array for the FFT to work on.

The parameter I am passing to the sinusoid for the amplitude is 0.5 as a q15, and the result that is returned from msp_sinusoid has a peak amplitude of about +/-16384 decimal which makes sense.

When I run the FFT, I am having trouble interpreting the scaling of the result.

The MSP dsp lib user guide says that the results for a 256 point FFT can be interpreted as a q8 result +/- 127.00000, or as a int16_t result divided by 128.

If I want to compute the magnitudes of each of the complex results, is it best to use the _QNmag function in the Qmath library, and make N=8 , i.e. _Q8mag()?

If I do that, is the result then in q8 format? I want to get the magnitudes into dB eventually, so I presume I can stay in q8 format to get a dB result using +/- 128 dB, or is that too simplistic?

If I don't use QNmag, how do I get the correctly scaled magnitude from the interger real and imaginary parts?

Do I need to multiply each by 128 then square, add and square root?

I've gone round in circles on this, but I am quite new to the complexities of FP maths!

For the moment I am not too worried about precision and resolution etc.

TIA.

MSP432P401R: eUSCI interrupt servicing suboptimal/broken

$
0
0

Part Number:MSP432P401R

On various eUSCI parts an IV (interrupt vector) is defined that gives a numerical code that denotes which of the various interrupt sources for the actual vector has asserted, is enabled, and is the highest priority.  This is good.

However, reading this register has the side-effect of clearing the IFG associated with said IV.   This is bad.  Let me show why...

For example, let's talk about the transmission side of an eUSCI UART.  By definition, TXIFG being a 1 (asserted) indicates that the TXBUF is empty and another byte can be written to the TXBUF for transmission.  This is pretty fundamental.  If TXIFG is 0 one shouldn't write to TXBUF.

But now consider the following interrupt driven transmit code for an eUSCI UART.

First the sender:

error_t gps_send_block(uint8_t *ptr, uint16_t len) {
  if (!len || !ptr)
    return FAIL;

  if (m_tx_buf)
    return EBUSY;

  m_tx_len = len;
  m_tx_idx = 0;
  m_tx_buf = ptr;
  /*
   * On start up UCTXIFG should be asserted, so enabling the TX interrupt
   * should cause the ISR to get invoked.
   */
  //call Usci.enableTxIntr();
  BITBAND_PERI(EUSCI_A2->IE, EUSCI_A_IE_TXIE_OFS) = 1
  return SUCCESS;
}

m_tx_buf is used to hold the pointer to the buffer we want to transmit, m_tx_idx is where we are in that buffer (next byte to transmit), and m_tx_len is how many bytes we want to transmit.

We use the fact that TXIFG should be pending with an empty TXBUF to start us off as soon as we turn on the interrupt.

And here is the interrupt service routine.   Only the TX portion is shown.

void EUSCIA2_Handler() @C() @spontaneous() __attribute__((interrupt)) {
  uint8_t data;
  uint8_t *buf;

  switch(EUSCI_A2->IV) {
    case MSP432U_IV_TXIFG:
      if (m_tx_idx >= m_tx_len) {
        buf = m_tx_buf;
        // Usci.disableTxIntr();
        BITBAND_PERI(EUSCI_A2->IE, EUSCI_A_IE_TXIE_OFS) = 0;
        m_tx_buf = NULL;
        gps_send_block_done(buf, m_tx_len, SUCCESS);
        return;
      }
      data = m_tx_buf[m_tx_idx++];
      // Usci.setTxbuf(data);
      EUSCI_A2->TXBUF = data;
      return;
  }
}

Now on the last byte, we will interrupt, m_tx_idx will be m_tx_len - 1, we will stuff the last byte into the TXBUF and return from the interrupt.  When the last byte has been transfered from TXBUF into the shift register for transmission, TXIFG will come up again and we will interrupt.

By reading the IV register in the switch statement, TXIFG will be cleared.  We will see that m_tx_idx is >= m_tx_len and enter the termination clause.  We will disable the TxInterrupt and do the call out indicating that the transmission has completed.

But note that TXBUF is empty and TXIFG is clear saying TXBUF is full.  That is wrong.  This a direct result of the side effect of clearing TXIFG whne reading EUSCI_A2->IV and the TXIFG interrupt is the highest priority.  If we try to fire up another send_block it will fail because when we turn on the interrupt the TXIFG is down and we won't enter the interrupt routine to start the new send up.  TXIFG will never come up again because there is nothing that would kick it.  We could write to TXBUF and that would eventually get things working again, but that technically is a no-no because one should write to TXBUF unless TXIFG being 1 says that TXBUF is empty.

Work arounds:

1) reorder the interrupt routine to be something like:

void EUSCIA2_Handler() @C() @spontaneous() __attribute__((interrupt)) {
  uint8_t data;
  uint8_t *buf;

  switch(EUSCI_A2->IV) {
    case MSP432U_IV_TXIFG:
      data = m_tx_buf[m_tx_idx++];
      // Usci.setTxbuf(data);
      EUSCI_A2->TXBUF = data;
      if (m_tx_idx >= m_tx_len) {
        buf = m_tx_buf;
        // Usci.disableTxIntr();
        BITBAND_PERI(EUSCI_A2->IE, EUSCI_A_IE_TXIE_OFS) = 0;
        m_tx_buf = NULL;
        gps_send_block_done(buf, m_tx_len, SUCCESS);
      }
      return;
  }
}

So when the last byte is written, we detect this and disable interrupts.   Because interrupts are disabled for TXIFG, when the hardware finishes sending the byte in the shift register and copies TXBUF down to the shift register, TXBUF will go empty, TXIFG will go to a 1, and no interrupt will happen.  Because no interrupt occurs, EUSCI_A2->IV isn't read and the problem doesn't occur.  There is a valid state, meaning TXBUF is empty and TXIFG is asserted indicating that this is the case.

So what is the problem with this work around.  When we signal completion, the hw state is TXBUF is full and TXIFG is deasserted.  Signalling completion indicates that the current send is done and you can fire up another one if you want.  If another send is immediately fired up, it will have to wait for the still in progress prior send to complete.  This will be one byte time which at slow baud rates can be significant.

But it can work and is what I am currently doing on my MSP432 based designs.

2) Replace the IFG that the IV read killed.

In the first example interrupt handler, place BITBAND_PERI(EUSCI_A2->IFG,EUSCI_A_IFG_TXIFG_OFS) = 1.  This will reassert the TXIFG.

However, it is unclear how this interacts with the rest of the hardware.  The BITBAND operation will instruct the memory system to do an atomic access to the peripheral register holding the TXIFG flag.  But what isn't clear is how the rest of the eUSCI h/w interacts with this register.  For example, if an RXIFG needs to be set (or STTIFG, start interrupt flag), is it possible to lose this flag because of interactions with the memory system setting the IFG register on behalf of the TXIFG write?

In other words, ensuring there isn't a h/w race condition is problematic.

In conclusion, it is problematic/sub-optimal having the h/w interrupt system automatically clear the TXIFG flag.  Doing so creates an invalid state for the h/w in question causing problems.

It would be best in the future to not do that kind of thing.

MSP430F5308: USCI I2C Mapping

$
0
0

Part Number:MSP430F5308

Hello Team,

Can you help clarify the mapping capability for MSP430F5308? In particular, I see in table 1 of the datasheet that only the RGC and ZQE packages support 2xI2C channels, since port 3 pins are not included on the PT and RGZ packages, however I also see that USCI_B0 is listed in the mapping capabilities for port 4 in table 8. Is it possible to map both I2C modules to the P4 port? For example:

Pins 4.1/4.2 = USCI_B1 I2C port

Pins 4.6/4.7 = USCI_B0 I2C port

Best Regards,

Casey McCrea

CCS/MSP430FR6989: How can I measure current consumption in real time without using Energy Trace?

$
0
0

Part Number:MSP430FR6989

Tool/software: Code Composer Studio

Hi,

I'd like to measure current consumption in order to use its values in a code of a host computer, because of this a graphic tool as ET or ET++ is not suitable. I'd also like to use a method that provides me only the device (MCU) and its peripherals consumption not including the consumption from the own circuit which is measuring.

Thank you!

 

MSP-EXP432P401R: 'What are 'unused pins used for? And some other questions...

$
0
0

Part Number:MSP-EXP432P401R

I am utilizing this micro-controller to implement a telemetry system for a high altitude air balloon.  Currently I have two temp sensors working (ADC14) and pressure sensor (I2C) working.  I'm currently working on implementing an SD card reader and a GPS unit.  The card reader is an 'OpenLog' and the GPS is the Venus638FLPx.  Both are made by sparkfun and were not chosen by me.  So here are a few questions, I apologize if this post is overloaded.  

First:  This board has a bunch of pins on J5 that are 'unused'.  Can I configure these pins for usage?  I2C or SPI maybe?  I cannot find any documentation on this.

Second:  Would I be better off buying an sd card reader such as:  

And interface with it directly via SPI or continue to attempt to implement the OpenLog, which I find to be less than satisfactory on the documentation side of the house.  

I have looked into the Booster packs for this board but weight is a concern so they have been excluded.  

MSP432P401R: I2C code hangs at MAP_I2C_masterSendMultiByteStart

$
0
0

Part Number:MSP432P401R

I have built a new board and I am trying to get I2C functionality to work. My code is hanging whenever I call MAP_I2C_masterSendMultiByteStart. Specifically at this point in the driverlib function: 

    while (!BITBAND_PERI(EUSCI_B_CMSIS(moduleInstance)->rIFG.r, UCTXIFG_OFS))
        ;

I am using the example, updated for the SCL and SDA Pins I am using (P6.6 - UCB3SDA, AND P6.7 - UCB3SCL)

Attached is the code I have. What is causing it to hang?

When I look at my code from a logic analyzer, it shows that only SDA is sending data, and nothing is happening on SCL.

I fixed a hardware error (toombstoned termination resistor) on the SCL line, and now I get nothing on my logic analyzer at all. All connections on the bus seem to be intact, and there does not appear to be any more hardware errors. The termination resistors are 3.3K ohm.

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

MSP430F449: LFXT1 - Absolute accuray and drift of Cxin and Cxout

$
0
0

Part Number:MSP430F449

Team,

We are stating the typical capacitance values for Cxin and Cxout in our datasheet (screenshot below).

Do we have the max values?
Can you give the values for absolute accuracy and drift of those values?


Thanks for your support!


CCS/msp430f5659: msp430f5659 bsl by another mcu.

$
0
0

Part Number:msp430f5659

Tool/software: Code Composer Studio

Hi,

I'm using msp430f5659 mcu.

i want  to update firmware by another mcu(nordic nRF52832).

msp430f5659 is connected by spi with nRF52832 in my schematic.

I planned over-the-air programming for msp430f5659 through nRF52832.

I know msp430f5xx series support UART, I2C and USB BSL.

I thought it is possible to convert spi(connected with msp430 and nRF52)  to I2C or UART.

And download binary code from nRF52 by I2C or UART.

Or, Saving binary code(downloaded from nRF52 by spi) to msp430 external nand flash and load binary code when bsl excuted

Is it possible?

Thank you.

Regards

Youngjun.

MSP430F5342: measurment on ADC A9

$
0
0

Part Number:MSP430F5342

Hi.

I'd like to measure voltage on P5.1 (ADC A9) on MSP430F5342 with internal 2.5V reference. Power supply for uP is > 2,8V.
Measurement is always wrong and never stable. When I measure on other channels (A0, A1, ...), measurement is OK.

Is it possible that channel A9 can't be use to measure voltage with internal 2.5V reference?

In MSP430F5342 data sheet there are two option for A9 pin: A9/VeREF- and A9/VREF-. Maybe is there a problem...

Thanks for any suggestions and comments.

Here are my register setup:

P5SEL |= BIT1;
REFCTL0 &= ~REFMSTR; 
ADC12CTL0 = ADC12SHT02 + ADC12ON + ADC12REFON + ADC12REF2_5V; 
ADC12CTL1 = ADC12SHP; 
ADC12MCTL0 = ADC12SREF_1 + ADC12INCH_9;
ADC12IE = 0x01; 
__delay_cycles(5000); // Vref settle
ADC12CTL0 |= ADC12ENC;
__bis_SR_register(LPM3_bits + GIE); // LPM3, ADC12_ISR will force exit
__no_operation(); 

// Interrupt rutine
#pragma vector = ADC12_VECTOR
__interrupt void ADC12_ISR(void)
{ 
    ADC12IFG &= ~0x01;
}


MSP432P401R: BSL Scripter not working on linux

$
0
0

Part Number:MSP432P401R

Hi,

i have compiled the BSL Scripter myself and have it running on ARM architecture running Debian Linux.

So here is the output:

root@:/BSL_QT# ./BSL_QT MSP432/script_MSP432_uart.txt
---------------------------------------------------------
BSL Scripter 3.2.1
PC software for BSL programming

---------------------------------------------------------
Input file script is : /home/BSL_QT/MSP432/script_MSP432_uart.txt
//
//Script example MSP432 UART BSL
//Device : MSP432P401R
//Download blink application to
//MSP432 device through UART BSL
//
LOG
MODE P4xx UART 9600 /dev/ttymxc3
[ERROR_MESSAGE]Initialization of BSL P432 failed! Exit the scripter!

 

Do i have to flash the MSP432 with BSL configuration first?

I am using the UART BSL Ports P1.2 and P1.3 and they are working fine with my Linux system, since i use them on my application.

The error message comes from the class UartComm from the SourceCode:

void UartComm::transmitP4xxInitialization()
{
const uint8_t loopInitialization = 10;
bool initP432 = false;
uint8_t uartTxBuffer[1] = { 0xFF };

for (uint8_t i = 0; i < loopInitialization; i++)
{
ack = 0xFF;
boost::system::error_code ec;
boost::asio::write(port, boost::asio::buffer(uartTxBuffer, 1), ec);
if (ec)
{
throw std::runtime_error("Error from writing occurs...");
}
receiveBuffer(-1);
if (ack == 0x00)
{
initP432 = true;
break;
}
}

if (initP432 == false)
{
throw std::runtime_error("[ERROR_MESSAGE]Initialization of BSL P432 failed! Exit the scripter!"); <---------------------------Here it throws the message
}
else
{
std::cout << "Initialization of BSL P432 succeed!" << std::endl;
}
}

The ack is from the "BslResponseHandler" class and  0x00 means: static const uint8_t FLASH_ACK = 0x00;

So BSL Scripter doenst receive 0x00 back and that is causing the scripter to stop.

But why is the MSP432 not sending 0x00 back but an other value?

Obs: Also measured the RX and TX UART lines and the communication is running

Thanks,

Michael

RTOS/MSP432P401R: Set a entire GPIO port at once (TI-RTOS driver)

$
0
0

Part Number:MSP432P401R

Tool/software:TI-RTOS

Hello,

I'm trying to connect a RA8835 LCD controller to the MSP432. I'm using the SimpleLink MSP432 SDK based on TI-RTOS. For the needed 8-bit bi-directional data bus i want to use the entire port 7. The GPIO driver (GPIO_write()) allows me only to set one pin at a time.

I also tried to use the Generic PIN & GPIO driver (PIN.h). As soon as I try to call a function of the Generic PIN & GPIO driver an error occurs:

 undefined first referenced
  symbol       in file     
 --------- ----------------
 PIN_open  ./display.obj   

error #10234-D: unresolved symbols remain
error #10010: errors encountered during linking; "VRC_main_MCU.out" not built

>> Compilation failure
makefile:167: recipe for target 'VRC_main_MCU.out' failed
gmake[1]: *** [VRC_main_MCU.out] Error 1
makefile:160: recipe for target 'all' failed
gmake: *** [all] Error 2

**** Build Finished ****

What am I doing wrong? Or is there a other way to set the entire port at once?

Thank you for your help & kind regards

Kevin

CCS/MSP-EXP430F5438: User experience demo

$
0
0

Part Number:MSP-EXP430F5438

Tool/software: Code Composer Studio

Hello!

I downloaded the zip file from ti website to obtain the user experience programs. Tried to build and debug them. Even after debug and run, the lcd screen doesn't light up with the TI logo like its supposed to. Maybe I'm going wrong with the way I'm going about the process. Could please guide me?

I am using ccsv6.1 and MSP-EXP430F5438 experimenter board.

Thank you!

CCS/MSP-EXP430FR5994: CCS/MSP-EXPFR5994 fatsd-tirtos example Failure to Run

$
0
0

Part Number:MSP-EXP430FR5994

Tool/software: Code Composer Studio

Hi.

Code Composer Studio  Version: 7.1.0.00016

I have a very very peculiar behavior i am seeing with a specific TI-RTOS example.

Specifically fatsd_MSP_EXP430FR5994_TI loaded from the Resource Explorer.

Software/TI-RTOS for MSP430-v:2.20.00.06/MSP-EXP-FR5994/Driver Examples/FatFs Examples/FatSD

If i import the example into project workspace and build and debug and load into target....no problems....it runs just fine.

If however i simply right click on the project and select properties and do absolutely nothing(make no changes)...other than say ok to the popup properties menu, the program ceases to be able to run. It builds and loads but gets stuck in a while loop servicing a interrupt stub that i am unaware of.

Pausing the debug....we are in HWFuncs.c....

__interrupt Void ti_sysbios_family_msp430_Hwi54(Void)
{
    while(1){};
}

I have made attempts at restricting the build from modifying the target and or src package directories...to no avail. Surely this is not the intended behavior of the example.

My overall goal is to be able to modify the properties in hopes of discovering why i cannot write a file larger than 32KBytes to the SD card, but i am unable to change them due to this frustrating issue.

I do have quite a bit of msp register programming experience and i reluctantly admit, there is much i do not quite yet understand using the ti-rtos.

any help that could be provided would be much appreciated.

thanks

Dennis

RTOS/TI-RTOS: Modification to FatFS file is not reflected back to the project

$
0
0

Part Number:TI-RTOS

Tool/software:TI-RTOS

Hi, 

I would like to use f_findfirst() & f_findnext() APIs of FatFS module.

Per the documentation, I modified _USE_FIND macro  to 1 in C:\ti\tirtos_msp43x_2_20_00_06\products\tidrivers_msp43x_2_20_00_08\packages\ti\mw\fatfs\ff.conf.h

However when I build the project (MSP430F5259, TI-RTOS 2.20.00.08) I keep getting "unresolved symbol f_findnext, first referenced" error as if _USE_FIND is still 0

I added "${COM_TI_RTSC_TIRTOSMSP430__TIDRIVERS_MSP43X}/ackages/ti/mw/fatfs" to my compilet include path but it didn't have any effect.

My question is how can I integrate the change into the project ? What should be included in the project properties (or elsewhere) ?

Thanks


MSP430F149: Timer working as PWM generator malfunction.

$
0
0

Part Number:MSP430F149

Hi, Sir or Madam

I am trying to generate SPWM with Time A on MSP430F149. But it has malfunction. The output does not toggle as programmed on the 3/4 cycle time. 

TACLK is 2MHz. The purple channel is output for TA0, toggled everytime counted to TACCR0, 402.

Yellow channel is for TA1, blue for TA2. 

You can see the dutycycle of each period is changing as sin function. But there is a period on both yellow and blue channel with 100% duty cycle. And that is wrong. I don't know why.

Do you know why? How to fix it? I can send you the code on email.

RTOS/TI-RTOS: Blocking mode UART return zero length buffer

$
0
0

Part Number:TI-RTOS

Tool/software:TI-RTOS

Hi, 

I initialize a UART as follow:

    uartParams.writeDataMode = UART_DATA_BINARY;	// Transmit data as-is
    uartParams.readDataMode = UART_DATA_BINARY;
    uartParams.readReturnMode = UART_RETURN_NEWLINE;	// Read is always TEXT based
    uartParams.readEcho = UART_ECHO_OFF;
    uartParams.baudRate = 115200;	
    uartParams.parityType = UART_PAR_NONE ;
    uartParams.stopBits = UART_STOP_ONE;
    uartParams.readMode = UART_MODE_BLOCKING;	// has a separate Task
    uartParams.readTimeout = UART_WAIT_FOREVER;
    uartParams.writeMode = UART_MODE_BLOCKING;
    uartParams.writeTimeout = UART_WAIT_FOREVER;

    uartHandle = UART_open(SR_UART_BLE, &uartParams);

Then in the task, I use 

while(1)	{
   len = UART_read(uartHandle, uartReadBuff, sizeof(uartReadBuff));
   if( (len>0) && (len < sizeof(uartReadBuff)-1))	{
      // do stuff
   }
   else	{
      System_printf("UART_read problem, len=%d\n",len);
      System_flush();
   }
}

Every now and then I get a zero len buffer...

I would expect that the minimal length be 1 character (Newline only). How can it be zero ?

Thanks

CCS/MSP430FR5969: On OSX, cannot connect to any USB port...

$
0
0

Part Number:MSP430FR5969

Tool/software: Code Composer Studio

Just got a brand-spankin' new MSP-EXP430FR5969 and am hoping to experiment a bit.

are all drivers provided available only for Windows? I hope not...

Am in the Out-of-Box GUI app in CCS. I cannot get dropdown list of USB ports to populate, so cannot do anything.

After Step 1, would like to access the TRF7970A BoosterPack we have attached to play with RFID.

It's not at all clear how the example code is organized. Is a firmware flash required? How to start with the basics?

Upon connecting the board, these serial ports do appear. Good sign, right?

/dev/cu.usbmodemFD131

/dev/cu.usbmodemFD133

Finally, any news on when Energia support for this board will be added? Was disappointed to learn that this (very new model) board is not supported there.

CCS/MSP430F149: The TAR of Timer_A counts discontinuously

$
0
0

Part Number:MSP430F149

Tool/software: Code Composer Studio

MSP430F149 --> TAR counts discontinuously

Hi Technican

I want to study about time interrupt of Timer_A.

I use MSP430F149, MSP-FET430UIF, Code Composer Studio 7.1.0.00016. I have a following program:

 

1   .cdecls C,LIST,  "msp430.h"

2   ;------------------------------------------------------------------------------

3             .def    RESET                    ; Export program entry-point to make it known to linker.

4             .text                            ; Program Start

5   ;------------------------------------------------------------------------------

6   RESET      mov.w   #0A00h,SP               ; Initialize stackpointer

7   StopWDT    mov.w   #WDTPW+WDTHOLD,&WDTCTL  ; Stop WDT

8   ;------------------------------------------------------------------------------

9   SetupBC    bic.b   #XT2OFF,&BCSCTL1        ; XT2 = on

10  SetupOsc   bic.b   #OFIFG,&IFG1            ; Clear OSC fault flag

11             mov.w   #0FFh,R15               ; R15 = Delay

12  SetupOsc1  dec.w   R15                     ; Additional delay to ensure start

13             jnz     SetupOsc1               ;

14             bit.b   #OFIFG,&IFG1            ; OSC fault flag set?

15             jnz     SetupOsc                ; OSC Fault, clear flag again

16             bis.b   #SELM_2+SELS,BCSCTL2    ; MCLK = SMCLK = XT2

17  ;------------------------------------------------------------------------------

18  SetupP2    bis.b   #001h,&P2DIR            ; P2.0 output

19  SetupC0    mov.w   #CCIE,&CCTL0            ; CCR0 interrupt enabled

20             mov.w   #4000,&CCR0

21  SetupTA    mov.w   #TASSEL_2+MC_2,&TACTL   ; SMCLK, continuous mode

22                  bis.w   #GIE,SR                 ; interrupts enabled

23  Loop_not   nop                                  ; For debugger

24             nop

25             nop

26             nop

27             nop

28             nop

29             jmp      Loop_not

30  ;------------------------------------------------------------------------------

31  TA0_ISR                                                                ; Toggle P2.0

32             xor.b   #001h,&P2OUT            ; Toggle P1.0

33             add.w   #4000,&CCR0             ; Add Offset to CCR0

34             reti                           

35  ;------------------------------------------------------------------------------

36  ;Interrupt Vectors

37             .sect   ".reset"                ; MSP430 RESET Vector

38             .short  RESET                   ;

39             .sect   ".int06"                ; Timer_A0 Vector

40             .short  TA0_ISR                 ;

41             .end

 

            I debug (run simulate), click Step Into.

At 21 line:

            TACLT (Hex): 0x0000

            TACCTL0 (Hex): 0x0010

            TACCTL1 (Hex): 0x0000

            TACCTL2 (Hex): 0x0000

            TAR (Decimal): 0

            TACCR0 (Decimal): 4000

At 22 line:

            TACLT (Hex): 0x0221

            TACCTL0 (Hex): 0x0011

            TACCTL1 (Hex): 0x0001

            TACCTL2 (Hex): 0x0001

            TAR (Decimal): 23473

            TACCR0 (Decimal): 4000

At 23 line:

            TACTL, TACCTL0, TACCTL1, TACCTL2, TACCR0 are unchanged, TAR=13918.

When click successively Step Into, TAR change: 63827 --> 40808 --> 55441 --> 41685...

On the other hand, every time reboot the value of the TAR is not the same as the previous times.

 

Result, the program runs wild.

I do not understand how TAR works. I think when the ID (Divider) bit is 00

then the TAR will counter: 0 --> 1 --> 2 --> 3 --> 4 --> 5 --> 6, ...65534 --> 65535 --> 0 --> 1 --> 0 ...

Please explain to me.

Thank you very much

Starterware/MSP-EXP430G2: Switch S2 not working

$
0
0

Part Number:MSP-EXP430G2

Tool/software: Starterware

#include <msp430.h> 

/*
 * main.c
 */
int main(void) {
    WDTCTL = WDTPW | WDTHOLD;	// Stop watchdog timer

    P1DIR = 0X40;
    P1DIR&=~0x08;
    P1REN = 0x08;
    P1OUT |= 8;


    while(1){

    	if((P1IN & 0x08 )== 0x08){

    	P1OUT = 0X40;
    	_delay_cycles(50000);
        P1OUT = 0;
    	_delay_cycles(500000);
    	}
    	else
    	{
    	 
    		P1OUT = 0X40;
    		
    	}


    }
	
	return 0;
}

I am using this code for using onboard switch S2 as input. It wasn't working.

Then I don't know why but I connected P1.3 and P1.2 using a Jumper and it all worked fine.

Can you tell me what happened here? Also how can I make it work without using the jumper?

Viewing all 21997 articles
Browse latest View live


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