int main (void) { configClock (); PORTE.DIR = 0b11000000; PORTF.DIR = 0b00001111; while (1) { PORTE.OUT = 0b00000000; // set floating PORTF.OUT = 0b00000000; // set floating __asm__ volatile ( "nop" ); // wait a bit (hundredish nanoseconds) __asm__ volatile ( "nop" ); __asm__ volatile ( "nop" ); __asm__ volatile ( "nop" ); PORTE.OUT = 0b01000000; // set channel 2 outputs high PORTF.OUT = 0b00000101; // set channel 2 outputs high _delay_us (20); PORTE.OUT = 0b00000000; // set floating PORTF.OUT = 0b00000000; // set floating __asm__ volatile ( "nop" ); // wait a bit (hundredish nanoseconds) __asm__ volatile ( "nop" ); __asm__ volatile ( "nop" ); __asm__ volatile ( "nop" ); PORTE.OUT = 0b10000000; // set channel 2 outputs low PORTF.OUT = 0b00001010; // set channel 2 outputs high _delay_us (20); } }
void main(void){ configClock(); setupPorts(); setupTimer(); _EINT(); // Not really necessary since CPU is going to LPM3 @ the main TACCTL0 &= ~CCIE; while(1) { __low_power_mode_3(); //enter LPM3 w/GIE } }
int16_t main(void) { //TODO discharge calculations int i = LTC3; int j; char voltages[19]; int selfCheck = 0; configPins(); configClock(); //Comment out next 5 lines if debugging selfCheck += initLTC(); selfCheck += initADC();//initADC(); if(selfCheck == 2){ setRelay(RELAY_ON); } while(1) { //comment out next 4 lines if debugging for(i = LTC1; i < LTC_ALL; i++){ LTC_readVoltages(i); } checkADC(); //uncomment next 0 lines if debugging RS-485 //unComment next 3 lines if debugging LTC //LTC_writeConfig(LTC_ALL, 0); //LTC_readVoltages(i); //LTC_analyzeVolts(i); //uncomment out next 3 lines if debugging ADC // j = ADCReadRaw(TEMP1_CHANNEL); // j++; // j--; } }
int main (void) { passedCenterFlag = 0; configClock (); PORTE.DIR = 0b11000000; PORTF.DIR = 0b00001111; PMIC.CTRL |= PMIC_HILVLEN_bm; PMIC.CTRL |= PMIC_LOLVLEN_bm; TCF0.CCABUF = STARTUP_PWM; TCF0.CCBBUF = STARTUP_PWM; TCF0.CCCBUF = STARTUP_PWM; TCF0.CCDBUF = STARTUP_PWM; TCE0.CCABUF = STARTUP_PWM/2; TCE0.CCBBUF = STARTUP_PWM/2; TCE0.CCCBUF = STARTUP_PWM/2; TCE0.CCDBUF = STARTUP_PWM/2; configPWM (&TCF0, &HIRESF, 5000); configHalfPWMTimer (&TCE0, &HIRESE, 5000); TCF0.CNT = 0; TCE0.CNT = 0; configDelayTimer (&TCC0); initAdc (&ADCA); initAdc (&ADCB); sei(); startup(); //~ autoCommutationFlag = 1; // float everything //~ SET_phaseOutputsEHigh(0); //~ SET_phaseOutputsEHigh(0); //~ //~ SET_phaseOutputsELow(0); //~ SET_phaseOutputsELow(0); //~ //~ SET_phaseOutputsFHigh(0); //~ SET_phaseOutputsFHigh(0); //~ //~ SET_phaseOutputsFLow(0); //~ SET_phaseOutputsFLow(0); //~ //~ PORTE.OUT = 0; //~ PORTF.OUT = 0; _delay_ms(1000); _delay_ms(1000); TCF0.CCBBUF = 1600; TCE0.CCBBUF = 1600/2; spiInit (); while (1) {} }
int main(int argc, char** argv) { unsigned short x = 0; //Blinking led counter SerialFrame frame; /* Port and interupts configurations */ configClock(); configPorts(); configInterruptPriority(); configTimer(); /* Initialize the serial port */ Serial_configSerialPort(); /* Preparing the frame */ CyclicBitBuffer_init(); RF433_init(); /* The frame content is assigned with the cyclicBitBuffer */ frame.content = CyclicBitBuffer_getBuffer(); /* The micro initilisation is over, let's begin the main loop */ while(1) { while( 0 == Serial_readFrame(&frame)) { x++; if(CyclicBitBuffer_flags.recordOver) { frame.content = CyclicBitBuffer_getBuffer(); frame.lenght = CyclicBitBuffer_size(); Serial_sendFrame(&frame); CyclicBitBuffer_flags.recordOver = 0; } if(0 == x) { PIN_DEBUG_OUTPUT ^= 1; } } disableInterupts(); CyclicBitBuffer_clearEvent(); /* Realise the frame management */ if(DOM_RECORD == frame.header) {//record //Delay1KTCYx(255); frame.header = DOM_RECORD; RF433_receive(&(frame.lenght)); } else if(DOM_TRANSMIT == frame.header) { //transmit; RF433_transmit(); frame.header = DOM_TRANSMIT; frame.lenght = 0; Serial_sendFrame(&frame); } else if(DOM_ECHO == frame.header) { frame.header = DOM_ECHO_REPLY; Serial_sendFrame(&frame); } else { frame.header = DOM_ERROR; frame.lenght = 0; Serial_sendFrame(&frame); } } }