Hello All, I am very new to MSP430 and so far I have built some simple circuits like LED blinking, UART transmission etc. For most of the stuff I used the code examples provided by TI on their site. Most of the pheripheral block's usage are provided in the example set, however I cant seem to find any example on pulse width measurement. I would like to measure the pulse period ( pulse output signal is from an accelerometer ) and I am a bit confused as to which should I use Timer_A or Timer_B? I am using a FG439 demo board for the experiments and the sensor output is connected to P2.0. Is there an example somewhere that I could look up. Or any pointer as to which registers should I look to initialise and how to set up the interrupt capturing? Thank You. Sim PS: This is my first post here and I am not asking anyone to do my homework, its just that I learn faster by looking at example first then look at the datsheet. I would realy appriciate any example code that shows how to implement pulse width measurement.
Getting started with pulse capturing
Started by ●February 12, 2006
Reply by ●February 14, 20062006-02-14
It doesn't make too much difference whether you use TimerA or TimerB,
but you should use the timer which is running at the highest possible
frequency to obtain the best results. I haven't included everything, it
would take up too much space. Things like I/O initialisation clock set
up etc etc. Just tyhe basics, enabling the timer ints, and the ISRs
themselves.
To speed up subsequent calculations this program reserves R7-R10 for
accelerometer readings, with the period being stored in R8/10 and the
duty cycle time stored in R7/9. Once the program has both values it sets
a flag (GOTX/Y) to indicate to the Main program that data is available.
There are several ways this could be handled. The next step in
processing would be to normalise the readings against pre-stored
calibration data. This may include temperature data too. I haven't
included these because I handle the output in a non-standard manner.
Cheers
Al
/**************************************************************
INITIALISATION ADXL202 ACCELEROMETER
x AXIS IS ON TB.0
Y AXIS IS ON TB.1
*************************************************************/
INIT_ADXL:
BIS.B #ADXLPWR1+ADXLPWR2,&P5OUT ;TURN THE ADXL ON!!
CLR &XCOUNT
CLR &YCOUNT
BIC #CCIFG,&CCTLB0 ;CLEAR PENDING INTS
BIS #CCIE+CAP+CM0,&CCTLB0 ;ENABLE
INT/CAP/RISING/SOURCE=PIN
BIC #CCIFG,&CCTLB1 ;CLEAR PENDING INTS
BIS #CCIE+CAP+CM0,&CCTLB1 ;ENABLE
INT/CAP/RISING/SOURCE=PIN
RET
;****** Timer_B 0 is X AXIS INPUT
TB0_ISR:
BIC #CCIFG,&CCTLB0
PUSH R5
MOV &CCRB0,R5
SUB &XT0,R5
BIT #CM0,&CCTLB0 ;TEST IF RISING EDGE DETECT
JNZ DO_XT2 ;IF SO PROCESS T2 EVENT
MOV R5,R7 ;STORE T1, R12 IS XT1
JMP XDONE ;ALL DONE
DO_XT2:
MOV R5,R8 ;STORE T2
MOV &CCRB0,&XT0 ;PLACE NEXT T0
BIS #GOTX,&SYSTEM_FLAGS ;INDICATE X AXIS DONE
XDONE:
XOR #CM1+CM0,&CCTLB0 ;FLIP DETECT EDGE
POP R5
RETI
sim_msp430 wrote:
>Hello All,
>
>I am very new to MSP430 and so far I have built some simple circuits
>like LED blinking, UART transmission etc. For most of the stuff I
>used the code examples provided by TI on their site. Most of the
>pheripheral block's usage are provided in the example set, however I
>cant seem to find any example on pulse width measurement.
>
>I would like to measure the pulse period ( pulse output signal is
>from an accelerometer ) and I am a bit confused as to which should I
>use Timer_A or Timer_B? I am using a FG439 demo board for the
>experiments and the sensor output is connected to P2.0.
>
>Is there an example somewhere that I could look up. Or any pointer as
>to which registers should I look to initialise and how to set up the
>interrupt capturing?
>
>Thank You.
>Sim
>
>PS: This is my first post here and I am not asking anyone to do my
>homework, its just that I learn faster by looking at example first
>then look at the datsheet. I would realy appriciate any example code
>that shows how to implement pulse width measurement.
>
>
>
>
>
>
>
>
>
>.
>
>
>Yahoo! Groups Links
>
>
>
>
>
>
>
>
>
>
>
>
>