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.

Compiler/MSP430F5310: Pwm input

Part Number: MSP430F5310

Tool/software: TI C/C++ Compiler

Hi

I want to read fan speed through pwm

my msp430 only has pin P2.4/TA2.1(FAN_SPEED_R) as input as follows

I want to know how to get fan info from the pin

Thanks in advanced.

Best Regards

Ken

  • What sort of signal is FAN_SPEED_R? Is it a once-per-rev tick, or a high-frequency PWM drive?

    A once-per-rev will be pretty slow (a few-100 Hz at most) so your best bet would be to use timer Capture (TA2.1=timer TA2, register CCR1) and subtract the capture values from consecutive edges. [Ref User Guide (SLAU208Q) Sec 17.2.4.1]

    I don't see any Capture examples in Resource Explorer, but there are some timer-A skeletons you might be able to use:

    https://dev.ti.com/tirex/explore/node?node=AEC6YEnWUPrjclYUKg9ntw__IOGqZri__LATEST

  • TA2CCTL1 = CM_1 + CCIS_0 + SCS + CAP; //capture on rising mode, CCI2A input, synchronous capture, capture mode
    TA2CTL = TASSEL_2 + MC_0; //SMCLK, timer halted
    
    
    #pragma vector=TIMER2_A1_VECTOR
    __interrupt void TIMER2_A1_ISR(void)
    {
    	switch(__even_in_range(TA2IV,14)){
    		case  0: 
    			break;                          // No interrupt
    		case  2:
    			new_cap = TA2CCR1;
    			cap_diff = new_cap - old_cap;
    			old_cap = new_cap;
    			if(max_cap < cap_diff){
    				max_cap = cap_diff;
    			}
    			if(min_cap > cap_diff){
    				min_cap = cap_diff;
    			}
    			TA2CTL = TASSEL_2 + MC_0;
    			TA2CCTL1 &= ~CCIE;
    			__no_operation();
    			break;                          // CCR1
    		case  4:
    			break;                          // CCR2
    		case  6: 
    			break;                          // reserved
    		case  8: 
    			break;                          // reserved
    		case 10: 
    			break;                          // reserved
    		case 12: 
    			break;                          // reserved
    		case 14: 
    			break;                          // overflow
    		default:
    			break;
    
    	}
    	
    }

    I enable TA2CCTL1 every 2 secs

    In debuging process, the value of cap_diff is 200 ~ 218

    Could someone tell me how to transfer the value into fan rpm??

  • Supposing you haven't changed the clocks (and ID=0) SMCLK is running at about 1MHz. So 200 reflects (200 ticks/ 1M ticks/sec)=200 usec. 1/200usec is 5kHz. 5kHz*60=300k RPM, so I suspect this isn't a once-per-rev.

**Attention** This is a public forum