int main(void) { __disable_interrupt(); sys_init(); __delay_cycles(8000000);//Защита от коротких нажатий P1OUT |= BIT6; //защелкиваем питание led(1); ADC10_Init(); AFE_Init(); rf_init(); TACCR0 = 0xFFFF;// запуск таймера __enable_interrupt(); while (1) { if(rf_rx_data_ready_fg) { onRF_MessageReceived(); rf_rx_data_ready_fg = 0; } if (packetDataReady){ uchar packetSize = assemblePacket(); rf_send((uchar*)&packet_buf[0], packetSize); packetDataReady = 0; } if(rf_rx_data_ready_fg || packetDataReady){ // идем по циклу снова }else{ __bis_SR_register(CPUOFF + GIE); // Уходим в спящий режим } } }
/***************************************************************************** * MAIN PROGRAM ******************************************************************************/ void main(void) { WDTCTL = WDTPW + WDTHOLD; //Stop Watchdog Timer ADC10_Init(); //Initialize ADC10 while (1) { ADC10CTL0 |= ENC + ADC10SC; //Enable ADC10, Start sample - conversion while (ADC10CTL1 & ADC10BUSY); adc_result = ADC10MEM; volt = adc_result * Vref / 1023; Vi = volt / 5.7; Ic = Vi / 10000; _delay_cycles(500000); } }
void main(void) { Config_stop_WDT(); Config_Clocks(); uart_init (); timer_init(); ADC10_Init (); __enable_interrupt(); _BIS_SR(GIE); P2DIR |= BIT3; //+BIT7;//6:cts-------7:rts //P2DIR &= ~BIT6; P2OUT |= BIT3; //+BIT7 ; ADC10CTL0 |= ENC + ADC10SC; //Enable ADC10, Start sample - conversion delay_ms (200); // send[0]=0x7E; send[1]=0x00; send[2]=0x07; send[3]=0x01; send[4]=0x01; send[5]=0x00; send[6]=0x01; send[7]=0x00; send[8]=0x31; send[9]=0xCB; while (1) { volt1=volt; checksum=203-volt1; }}
void main(void) { uchar display[6]; WDTCTL = WDTPW | WDTHOLD; // Stop watchdog timer Clock1MHZ_Init(); ADC10_Init(); LCD1602_Init(); TLC5615_Init(); Button_Init(); __enable_interrupt(); ADC10_Enable(); while(1) { TLC5615_Convert((uint)(DA_Output * 512 / 3.555f)); __delay_cycles(50000); NumberToString(display, ADC_Convert(ADC_Value[0])); LCD1602_Show(0, 0, display); __delay_cycles(50000); } }
int main(void) { __disable_interrupt(); sys_init(); led(1); ADC10_Init(); AFE_Init(); rf_init(); TACCR0 = 0xFFFF; // запуск таймера __enable_interrupt(); while (1) { if (rf_rx_data_ready_fg) { onRF_MessageReceived(); rf_rx_data_ready_fg = 0; } if (packetDataReady) { uchar packetSize = assemblePacket(); rf_send((uchar*) &packet_buf[0], packetSize); packetDataReady = 0; } if (rf_rx_data_ready_fg || packetDataReady) { ; // идем по циклу снова } else { __bis_SR_register(CPUOFF + GIE); // Уходим в спящий режим } } }