int main( void ) { WDTCTL = WDTPW + WDTHOLD; // Stop watchdog timer BCSCTL1 = CALBC1_1MHZ; // Set range (1 Mhz) DCOCTL = CALDCO_1MHZ; // Set DCO step + modulation */ SPI_Master_Init(); P1OUT &= ~(BIT0 + BIT1); // Set P1.0 and P1.1 to 0 (when output) P1DIR |= (BIT0 + BIT1); // Set P1.0 and P1.1 to output direction timerInterruptFlag=CLEAR; ConfigTimer0(); //Configure Timer0 Module //for 10 ms interrupt _EINT(); // enable (general) interrupts //eint <-----> bis #8,sr //example of a timed loop: for(;;) { // loop forever while(timerInterruptFlag != SET); // loop forever while Flag not SET timerInterruptFlag=CLEAR; // Clear timer flag Counter(); } return 0; }
/* * Main function */ void main(void) { TRISB = 0x00; //configuring all portb bits as outputs PORTB = 0; //force 0 state to all outputs TRISA = 0xFF; //configuring all porta bits as inputs //init displays´ values SetValuesDisplays(0,0,0); //init time counter InitTimeCounter(); //init tasks and config Timer0 InitTasks(); ConfigTimer0(); //main loop while(1) { //Verification: check if there´s a task to be executed if ((Timer0IntGeneraed == YES) && (NUMBER_OF_TASKS)) { Timer0IntGeneraed = NO; ExecuteTask(); } } }
int main( void ) { WDTCTL = WDTPW + WDTHOLD; // Stop watchdog timer BCSCTL1 = CALBC1_1MHZ; // Set range (1 Mhz) DCOCTL = CALDCO_1MHZ; // Set DCO step + modulation */ SPI_Master_Init(); //Pull up resistor in P1.3++++++++++++++++++++++++++++++++++++++++++++++++++ P1OUT |= BIT3; // Bit 3 of P1OUT in 1 P1REN |= BIT3; // Bit 3 of P1REN in 1 // REN:Pullup/Pulldown Resistor Enable // register //-------------------------------------------------------------------------- //Hi/Low transition detection+++++++++++++++++++++++++++++++++++++++++++++++ P1IES |= BIT3; // P1.3 Hi/Low transition detection // IES:Interrupt Edge Select register P1IFG &= ~BIT3; // P1.3 IFG cleared // IFG:Interupt Flag register //-------------------------------------------------------------------------- ConfigTimer0(); //Configure Timer0 Module //for 10 ms interrupt _EINT(); // enable (general) interrupts //eint <-----> bis #8,sr //example of a timed loop: for(;;){ // loop forever while(timerInterruptFlag != SET); // loop forever while Flag not SET timerInterruptFlag=CLEAR; // Clear timer flag // LedsShifter_a(); // LedsShifter_b(); // EvaluateInputTransition(); //Find if a transition has happened // SequenceController(); //Select desired sequence } return 0; }
/* * Main function */ void main(void) { /* * example of input and output configuration. It can be changed according to what you need */ TRISB = 0x00; //configures all bits of PORTB as outputs PORTB = 0; //sets all portb´s outputs to 0 TRISA = 0xFF; //configures all bits of PORTA as inputs //init tasks and config Timer0 InitTasks(); ConfigTimer0(); //main loop while(1) { //Verification: check if there´s a task to be executed if ((Timer0IntGeneraed == YES) && (NUMBER_OF_TASKS)) { Timer0IntGeneraed = NO; ExecuteTask(); } } }
int main( void ) { WDTCTL = WDTPW + WDTHOLD; // Stop watchdog timer BCSCTL1 = CALBC1_1MHZ; // Set range (1 Mhz) DCOCTL = CALDCO_1MHZ; // Set DCO step + modulation */ //Red1 On, Green1 Off +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ P1OUT=(P1OUT|BIT0)&(~(BIT1+BIT6)); // Set P1.0 to 1, P1.6 to 0 (when outputs) P1DIR |= (BIT0+BIT1+BIT6); // Set P1.0 and P1.6 to output direction //----------------------------------------------------------------------------- //NEW: Configure P2.6 and P2.7 as general I/O pins+++++++++++++++++++++++++++ P2SEL &= ~BIT6; // Configure P2.6 as I/O pin P2SEL &= ~BIT7; // Configure P2.7 as I/O pin // -------------------------------------------------------------------------- //Pull up resistor in P2.7++++++++++++++++++++++++++++++++++++++++++++++++++ P2OUT |= BIT7; // Bit 7 of P2OUT in 1 P2REN |= BIT7; // Bit 7 of P2REN in 1 // REN:Pullup/Pulldown Resistor Enable // register //-------------------------------------------------------------------------- //Hi/Low transition detection in P2.7+++++++++++++++++++++++++++++++++++++++++++ P2IES |= BIT7; // P2.6 Hi/Low transition detection // IES:Interrupt Edge Select register P2IFG &= ~BIT7; // P2.6 IFG cleared // IFG:Interupt Flag register //----------------------------------------------------------------------------- //Red2 On, Green2 Off +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ P2OUT=(P2OUT|BIT0)&(~(BIT1+BIT6)); // Set P2.0 to 1, P2.6 to 0 (when outputs) P2DIR |= (BIT0+BIT1+BIT6); // Set P2.0 and P2.6 to output direction //----------------------------------------------------------------------------- pulseCount=5; // pulses count for Red1 timeCount= 500; // time for Red2 (100x10ms = 1 seg) inputTransitionFlag=CLEAR; timerInterruptFlag=CLEAR; ConfigTimer0(); //Configure Timer0 Module //for 10 ms interrupt _EINT(); // enable (general) interrupts //eint <-----> bis #8,sr //Timed loop:+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ for(;;){ // loop forever while(timerInterruptFlag != SET); // loop forever while Flag not set to YES timerInterruptFlag=CLEAR; // reset timer flag LedsSequencer_A(); LedsSequencer_B(); } //--------------------------------------------------------------------------- return 0; }