void main( void ) { // Stop watchdog timer to prevent time out reset WDTCTL = WDTPW + WDTHOLD; // Increase PMMCOREV level to 2 in order to avoid low voltage error // when the RF core is enabled SetVCore(2); InitRadio(); InitButtonLeds(); Strobe(RF_SIDLE); Strobe(RF_SRX); // P2.7 for GD02 - synchronous clock from Radio // P2.6 for GDO0 - synchronous data from Radio P2DIR |= BIT6+BIT7; P2SEL |= BIT6+BIT7; PMAPPWD = 0x02D52; // Get write-access to port mapping regs P2MAP6 = PM_RFGDO0; // Map GDO0 to P2.6 P2MAP7 = PM_RFGDO2; // Map GDO2 to P2.7 PMAPPWD = 0x00; // Lock Port mapping while(1); }
void main( void ) { // Stop watchdog timer to prevent time out reset WDTCTL = WDTPW + WDTHOLD; // Increase PMMCOREV level to 2 for proper radio operation SetVCore(2); ResetRadioCore(); InitButtonLeds(); InitTimer(); // Clean out the RX Buffer rxPosition = PACKET_LEN+2; while(rxPosition--) { RxBuffer[rxPosition] = 0; } InitRadio(); ReceiveOn(); //Check RSSI here while (1) { P1IE |= BIT7; // Enable button interrupt __bis_SR_register( LPM3_bits + GIE ); __no_operation(); if (buttonPressed) // Process a button press->transmit { ReceiveOff(); // Button means TX, stop RX receiving = 0; TransmitPacket(); buttonPressed = 0; // Re-enable button press } if(receiving) { ReceivePacket(); __no_operation(); // Check CRC if(RxBuffer[CRC_LQI_IDX] & CRC_OK) //Got it! P1OUT ^= BIT0; // Toggle LED1 in celebration } if(!transmitting) { ReceiveOn(); } } }
void main( void ) { // Stop watchdog timer to prevent time out reset WDTCTL = WDTPW + WDTHOLD; TA1CCTL0 = CCIE; // CCR0 interrupt enabled TA1CCR0 = 50000; TA1CTL = TASSEL_2 + MC_1 + TACLR; // SMCLK, upmode, clear TAR __bis_SR_register(GIE); //WDTCTL = WDT_ARST_250; //SFRIE1 |= WDTIE; // Enable WDT interrupt // Increase PMMCOREV level to 2 for proper radio operation SetVCore(2); ResetRadioCore(); InitRadio(); InitButtonLeds(); InitUart(); ReceiveOn(); receiving = 1; _EINT(); while (1) { //WDTCTL = WDT_ARST_250; // __bis_SR_register( LPM3_bits + GIE ); __no_operation(); if((!(BUTTON_IN & (1<<BUTTON_BIT)))) { _NOP(); delayms(30); if(!(BUTTON_IN & (1<<BUTTON_BIT))) { _NOP(); buttonPressed = 1; LEDR_ON(); ReceiveOff(); receiving = 0; Transmit( (unsigned char*)TxBuffer,sizeof TxBuffer); transmitting = 1; while(!(BUTTON_IN & (1<<BUTTON_BIT))); } } if(!transmitting) { ReceiveOn(); receiving = 1; } if(buttonPressed && transmit == 1) { LEDR_ON(); ReceiveOff(); receiving = 0; Transmit( (unsigned char*)TxBuffer,sizeof TxBuffer); transmitting = 1; transmit = 0; receive = 1; delayms(500); buttonPressed = 0; } if(count == 20 && buttonPressed == 0 && receive == 1) { buttonPressed = 1; count = 0; transmit = 1; receive = 0; } } }
void main( void ) { // Stop watchdog timer to prevent time out reset WDTCTL = WDTPW + WDTHOLD; // Increase PMMCOREV level to 2 in order to avoid low voltage error // when the RF core is enabled SetVCore(2); InitRadio(); InitButtonLeds(); Strobe( RF_SIDLE ); Strobe(RF_SRX); P2DIR |= BIT6; // P2.6 output P2SEL |= BIT6; // P2.6 select //add P2.0 for GD02 - clock sync to TXDATA P2DIR |= BIT0; // P2.0 output P2SEL |= BIT0; // P2.6 select //map P1.0 to GDO1 - high if RSSI above threshold P1DIR |= BIT0; // P1.0 output P1SEL |= BIT0; // P1. select PMAPPWD = 0x02D52; // Get write-access to port mapping regs P2MAP6 = PM_RFGDO0; // Map GDO0 to P2.6 // P2MAP0 = PM_RFGDO2; // Map GDO2 to P2.0 // P1MAP0 = PM_RFGDO1; // Map GDO1 to P1.0 PMAPPWD = 0x00; // Lock Port mapping // Enable timer interrupts to see if input is visible TA1CTL = TASSEL__SMCLK + MC_2 + TACLR; TA1CCTL0 = CM_3 + CCIS_1 + CAP + CCIE; __bis_SR_register(GIE); while(1); #elif defined TEST_ASYNC_TX_MODE // Should serve as internal timer output (toggle rate 19.2 kHz) // to Radio TX input when IOCFG0 = 0x2E (high-Z) // NOTE: SMARTF_CC430 IOCFG0 should = 0x2E so asynchronous signal is taken from // the timer and not GDO0 // TA1CCR0 = 27; // TA1CCR1 = 27; TA1CCR0 = 26; TA1CCR1 = 26; TA1CCTL0 = OUTMOD_4; TA1CCTL1 = OUTMOD_4; TA1CTL = TASSEL__SMCLK + MC_1 + TACLR; P2SEL |= BIT2; P2DIR |= BIT2; PMAPPWD = 0x02D52; // Get write-access to port mapping regs P2MAP2 = PM_TA1CCR0A; // Map CBOUT output to P2.2 PMAPPWD = 0x00; // Lock Port mapping Strobe( RF_SIDLE ); Strobe( RF_STX ); //Transmit the TX waveform asynchronously while(1); #endif // ************NOT USED IN THIS LAB***************************** // Using function generator to generate asynchronous TX signal /* P2OUT |= BIT0; P2DIR |= BIT0; P2SEL |= BIT6; //add P2.0 for GD02 - clock sync to TXDATA P2DIR |= BIT0; // P2.0 output P2SEL |= BIT0; // P2.6 select PMAPPWD = 0x02D52; // Get write-access to port mapping regs P2MAP6 = PM_RFGDO0; // Map CBOUT output to P1.6 P2MAP0 = PM_RFGDO2; // Map GDO2 to P2.0 PMAPPWD = 0x00; // Lock Port mapping // NOTE: SMARTRF_CC430 IOCFG0 shoud = 0x2D so asynchronous signal is taken from // GDO0 and not the internal timer connection */ }