Proyecto de Tesis en Mecatrónica. Universidad Técnica del Norte. Ernesto Palacios <mecatronica.mid@gmail.com>

Dependencies:   EthernetNetIf HTTPServer QEI_hw RPCInterface mbed

Committer:
Yo_Robot
Date:
Sat Mar 24 04:40:21 2012 +0000
Revision:
2:a1b556d78a7f
Parent:
1:186187f69295
Child:
3:8d5a9e3cd680
Works! Still needs to figure out how the period and match register works, but for a Stepper motor the base code is there!

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Yo_Robot 2:a1b556d78a7f 1 // El siguiente código sirve de ejemplo para
Yo_Robot 2:a1b556d78a7f 2 // establecer un tren de impulsos y controlar
Yo_Robot 2:a1b556d78a7f 3 // su frecuencia.
Yo_Robot 2:a1b556d78a7f 4
Yo_Robot 2:a1b556d78a7f 5 #include "mbed.h"
Yo_Robot 2:a1b556d78a7f 6 #include "setup.h"
Yo_Robot 2:a1b556d78a7f 7
Yo_Robot 2:a1b556d78a7f 8 Serial pc( USBTX, USBRX );
Yo_Robot 2:a1b556d78a7f 9 DigitalOut myled( LED1 );
Yo_Robot 2:a1b556d78a7f 10
Yo_Robot 2:a1b556d78a7f 11 void Setup_PTO_Timer2();
Yo_Robot 2:a1b556d78a7f 12 void ISR_Serial();
Yo_Robot 2:a1b556d78a7f 13
Yo_Robot 2:a1b556d78a7f 14 uint32_t PRESCALER_STEP; //Steps for the preescaler
Yo_Robot 2:a1b556d78a7f 15
Yo_Robot 2:a1b556d78a7f 16 int main() {
Yo_Robot 2:a1b556d78a7f 17
Yo_Robot 2:a1b556d78a7f 18
Yo_Robot 2:a1b556d78a7f 19 pc.printf( "Teclee 'w' para aumentar, 's' para disminuir, 'z' cambia los pasos " );
Yo_Robot 2:a1b556d78a7f 20 PRESCALER_STEP = 50UL;
Yo_Robot 2:a1b556d78a7f 21 //The default prescaler will be 0.05 sec
Yo_Robot 2:a1b556d78a7f 22
Yo_Robot 2:a1b556d78a7f 23 Setup_PTO_Timer2();
Yo_Robot 2:a1b556d78a7f 24 pc.attach( &ISR_Serial );
Yo_Robot 2:a1b556d78a7f 25
Yo_Robot 2:a1b556d78a7f 26 uint32_t period = ( uint32_t LPC_TIM2->PR );
Yo_Robot 2:a1b556d78a7f 27 pc.printf( "\Period = %d", period );
Yo_Robot 2:a1b556d78a7f 28
Yo_Robot 2:a1b556d78a7f 29 while(1) {
Yo_Robot 2:a1b556d78a7f 30
Yo_Robot 2:a1b556d78a7f 31
Yo_Robot 2:a1b556d78a7f 32 }
Yo_Robot 2:a1b556d78a7f 33 }