This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

MSP430F2618: Interrupts

Part Number: MSP430F2618
Other Parts Discussed in Thread: MSP430G2553

Hello!

I am using YF‑S201 water flow sensor to measure the flow of water and read the data into msp430f2618 board. I referred to a code written for the same sensor for the msp430g2553 code and I am attaching that code here. Can anyone suggest the changes that are to be made to make it work with msp430f2618.

 

#include <msp430g2553.h>

void main(void) {

       WDTCTL = WDTPW + WDTHOLD;               // Stop watchdog timer

       TA0CCR0 = 0xFFFF;                              // Count limit (16 bit)

       P1SEL |= BIT0;                            // Use P1.0 as TimerA input

       P1SEL2 &= ~BIT0;                            //

       P1DIR &= ~BIT0;                             //

       P1OUT &= ~BIT0;                             // Enable pull down resistor to reduce stray counts

       P1REN |= BIT0;

       TA0CCTL0 = 0x10;                               // Enable counter interrupts, bit 4=1

       TA0CTL |= TACLR;

       TA0CTL |= TASSEL_0 + MC_1;

       _BIS_SR(LPM0_bits + GIE);           // LPM0 (low power mode) with interrupts enabled

}

 

#pragma vector=TIMER0_A0_VECTOR

   __interrupt void Timer0_A0 (void) {         // Timer0 A0 interrupt service routine

 

       //P1OUT ^= BIT0;                                      // Toggle red LED

}

Also where will the data from the sensor be stored?

  • Hello Amith,

    Please refer to the MSP430x261x_ta examples from the MSP430F241x, MSP430F261x Code Examples package (SLAC151) and modify as necessary. Most of the differences involve "TA" nomenclature instead of "TA0" since the timer clock still resides on P1.0. However this code example seems insufficient as you should instead be using timer capture mode to evaluate the sensor pulse against a known clock frequency. The hall effect sensor chosen also operates at 5 V, since the MSP430 can only accept input below 3.6 V you will need to use a level translator accordingly.

    Regards,
    Ryan
  • I am using a Logic Level Converter to bring down the 5V as needed by the msp430.

    The hardware I am using is from a private vendor which uses msp430f2618 board. It has a 14-pin configuration to connect the sensor and the configuration is as follows:

    Name                                                  Pin No.

    VCC                                                          1

    GND                                                          2

    P3.2/I2C_SCL                                           3

    P3.1/I2C_SDA                                           4

    P3.4/SPI_SIMO                                         5

    P3.5/SPI_SOMI                                         6

    P3.0/SPI_CLK                                           7

    P4.4/SPI_CS1                                           8

    P2.7/TA0/INT                                             9

    P2.5/INT                                                    10

    P3.6/RADIO_GPIO3/UART1TX                11

    P3.7/UART1RX                                         12

    P6.0/A0                                                     13

    P6.6/A6/DAC0                                           14

    If I am not wrong the output pin from the sensor has to be connected to the Pin 9 in my hardware. But most of the example codes use P1.0,2,3 and this hardware has P2.7 as the timer/interrupt pin I am getting confused.

  • Hi Amith,

    I googled the sensor and came to this page:

    It says two things about the output of the sensor: PWM output and output duty cycle of 50% (+/- 10%) with a pulse rate of 7.5 * l/min. This is no PWM in my eyes, so you do not need to measure the pulse width, only the frequency of the output. The "datasheet" again has some other values given - there is a table that says 120l/h results in a frequency of 16Hz, but 120l/h is 2l/min which would mean 8 * l/min. The documentation of the sensor is horrible, there are multiple supply voltage ranges given that say different things. And also another information about the pulse saying 7 * l/min...maybe the webiste decided to take the average of 7.5 ;-P

    Anyway - the maximum flow through the sensor is 30l/min, so the maximum frequency is 30 * 7.5 = 225Hz (The website says "Pulses per Liter: 450" - don't know what that means). This is very slow. If you are not familiar with the capture mode of the timer, you can count the pulses with an incrementing variable inside a pin interrupt and look how many pulses were counted in one second or any other time period.

    Dennis

**Attention** This is a public forum