// experi7e.c #include #include #include // defines OC structure #include "outcont.h" // include header with constants #include "constant.h" // include header with external prototypes #include "extern.h" enum { MainMotor, LED1, LED2, LASTSLOT }; void main(void) { int x; double dc,oldfreq,newfreq; oldfreq = 1193180.0/65536.0; get_port(); // get the port number and establish register locations // make everthing an output set_up_ppi(Aout_CUout_Bout_CLout); set_up_new_timer(2000.0); SetLast(LASTSLOT); newfreq = get_frequency(); printf("old frequency = %f new frequency = %f Hz\n" ,oldfreq,newfreq); Blink(LED1, PA3, .3, .2); Blink(LED2, PA4, .15, .1); SetLast(LASTSLOT); // set up an L289 L289PwmDuty(MainMotor, 0, // arraynumer, start direction PA0, 30.0, // pwm/enable port, fwrd duty 50.0, // reverse dutycycle PA2, // direction1 port PA1); // direction2 port printf("Settings from L289 setup:\n"); show(MainMotor); while(!kbhit()) { Forward(MainMotor); printf("Forward\n"); if(kbhit()) break; wait(1.25); Stop(MainMotor); printf("Stop\n"); if(kbhit()) break; wait(1); Reverse(MainMotor); printf("Reverse\n"); if(kbhit()) break; wait(.75); BrakeL298(MainMotor); printf("Brake\n"); if(kbhit()) break; wait(1); } Stop(MainMotor); // don't forget to free memory! FreeOutputControl(); // be sure to restore the timer! restore_old_timer(); } // end experi7e.c