예제 #1
0
파일: main.c 프로젝트: bpfender/EmbeddedC
void main(void)
{
    OSCCON = 0b11110010; // internal oscillator, 8MHz
    while(!OSCCONbits.IOFS); //Wait for OSC to become stable

    Interrupt_Setup();
    Timer_Setup();

    while(1)
    {

    }
}
예제 #2
0
파일: main.c 프로젝트: bpfender/EmbeddedC
void main(void)
{
    unsigned long left_wheel_total;
    unsigned long right_wheel_total;
    unsigned long left_wheel_comp;
    unsigned long right_wheel_comp;

    OSCCON = 0b11110010; // internal oscillator, 8MHz
    while(!OSCCONbits.IOFS); //Wait for OSC to become stable

    LATC=0;

    Interrupt_Setup();
    Timer_Setup();

    while(1)
    {
//        while(//rfid not read)
//        {
//        left_wheel_total=0xFFFF*left_wheel_overflow_counter + TMR5;     //total number of counts of encoder will be number of overflows*0xFFFF + current tmr value
//        right_wheel_total=0xFFFF*right_wheel_overflow_counter + TMR1;
//        }
//
//        left_wheel_overflow_counter=0;      //reset all values
//        right_wheel_overflow_counter=0;
//        TMR1=0;
//        TMR5=0;
//
//        while(//Go home)
//        {
//        left_wheel_comp=0xFFFF*left_wheel_overflow_counter + TMR5;     //total number of counts of encoder will be number of overflows*0xFFFF + current tmr value
//        right_wheel_comp=0xFFFF*right_wheel_overflow_counter + TMR1;
//
//        //PID control of wheels?
//
//        //or relative proportion of each?
//
//        }

        //may have to add additional direcional nuances (or ensure that they are always moving forwards
    }
}
예제 #3
0
int main(int argc, char** argv) {
    int xVal, yVal;

    void Ludacris_Speed_GO(void);
    Ludacris_Speed_GO();

    UART1_Config();
    Timer1_Setup();
    Pin_Setup();
    Interrupt_Setup();

    printf("\nWe're gon-na to get you...\n");

    while(1)
    {
        switch (PromptState)
        {
        case GETXINPUT:
        case GETYINPUT:
            if (PromptState == GETXINPUT)
            {
                if(!Prompted)
                {
                    printf("x = ");
                    Prompted++;
                }
                if(RX_Done)
                {
                    xVal = atoi(RX_Data);
                    PromptState = GETYINPUT;
                    Prompted = 0;
                    RX_Done = 0;
                    ClearString();
                }
            }
            if (PromptState == GETYINPUT)
            {
                if(!Prompted)
                {
                    printf("y = ");
                    Prompted++;
                }
                if(RX_Done)
                {
                    yVal = atoi(RX_Data);
                    PromptState = CALCULATE;
                    Prompted = 0;
                    RX_Done = 0;
                    ClearString();
                }
            }
            Prompted = 1;
            break;
        case CALCULATE:
            Calculate(xVal, yVal);
            printf("Press Enter to play again...");
            break;
        case WAITING:
            Nop();
            if(RX_Done)
            {
                PromptState = RESET;
                RX_Done = 0;
            }
            break;
        case RESET:
            Prompted = 0;
            T1CONbits.TON = 1;
            PromptState = WAITING;
        }
    }
    return (EXIT_SUCCESS);
}