I am working with the MSPF5529
I would like to set up a set of sampling pulses to drive a photogate on a pendulum. So the drive would be turned on just before it is needed, to measure the pendulum location.
The sampling pulses could be high frequency and low duty cycle say 300KHz and 10%. That could be created with one clock source and a divider. Then a much slower clock could generate a roughly 1 Hz "sample ON" pulse.
How do I combine these pulses logically? If each was assigned to an output pin, how do I create NAND, NOR, AND, OR etc?
So I am imagining I want " P4.7 = (P2.3 AND P2.5) " where 2.3 is HF and 2.5 is LF? I don't see how to name a pin with both the port and the pin number.
I ran the following code and it compiles, which surprised me, but it does not light the AND LED. The "fast" is 16 Hz here and the slow is 1 Hz. (The example is from the MSP Ware code for the MSPF5529.)
I also don't see how you could assign the AND to a different port such as P4.7 if the inputs were on another port such as P2.3 and P2.5
#include <msp430.h>//***MSP430F55xx_ta2_08.c***Timer2_A3, Toggle P1.0;P2.3-5,
// Cont. Mode ISR, 32kHz ACLK
int main(void)
{
WDTCTL = WDTPW + WDTHOLD; // Stop WDT
//P2SEL |= BIT3+BIT4+BIT5; // P2.3 - P2.5 option select
//P2DIR |= BIT3+BIT4+BIT5; // P2.3 - P2.5 outputs
P2SEL |= BIT3+BIT4+BIT5+BIT7; // P2.3 - P2.5 & P2.7 selected
P2DIR |= BIT3+BIT4+BIT5+BIT7; // P2.3 - P2.5 & P2.7 are outputs
P1DIR |= 0x01; // P1.0 - Outputs
TA2CCTL0 = OUTMOD_4 + CCIE; // CCR0 toggle, interrupt enabled
TA2CCTL1 = OUTMOD_4 + CCIE; // CCR1 toggle, interrupt enabled
TA2CCTL2 = OUTMOD_4 + CCIE; // CCR2 toggle, interrupt enabled
TA2CTL = TASSEL_1 + MC_2 + TACLR + TAIE; // ACLK =1, contmode, clear TAR,
// interrupt enabled
__bis_SR_register(LPM3_bits + GIE); // Enter LPM3, interrupts enabled
__no_operation(); // For debugger
}
// Timer2 A0 interrupt service routine
#if defined(__TI_COMPILER_VERSION__) || defined(__IAR_SYSTEMS_ICC__)
#pragma vector=TIMER2_A0_VECTOR
__interrupt void Timer2_A0 (void)
#elif defined(__GNUC__)
void __attribute__ ((interrupt(TIMER2_A0_VECTOR))) Timer2_A0 (void)
#else
#error Compiler not supported!
#endif
{
TA2CCR0 += 1024; // Add 1024 Offset to CCR0 = 16 Hz
}
// Timer2_A3 Interrupt Vector (TAIV) handler
#if defined(__TI_COMPILER_VERSION__) || defined(__IAR_SYSTEMS_ICC__)
#pragma vector=TIMER2_A1_VECTOR
__interrupt void TIMER2_A1_ISR(void)
#elif defined(__GNUC__)
void __attribute__ ((interrupt(TIMER2_A1_VECTOR))) TIMER2_A1_ISR (void)
#else
#error Compiler not supported!
#endif
{
switch(__even_in_range(TA2IV,14))
{
case 0: break; // CA2CCR0 value set at line 70 above
case 2: TA2CCR1 += 4096; // Add 4096 Offset to CCR1 4 Hz // works
break;
case 4: TA2CCR2 += 16384; // Add 16384 Offset to CCR2 1 Hz // works
break;
case 6: break; // CCR3 not used
case 8: break; // CCR4 not used
case 10: break; // CCR5 not used
case 12: break; // Reserved not used
case 14: P1OUT ^= 0x01; // overflow is 0.25 Hz
break;
default: break;
}
P2OUT = (BIT3 & BIT5); // attempt using AND, to get 1 Hz with 4 Hz modulation // fails
}