Robotic_winteam / Mbed 2 deprecated Nucleo_pwmdecoder

Dependencies:   mbed

Committer:
ooseausername
Date:
Wed May 25 06:03:39 2016 +0000
Revision:
1:836ed9afcb8a
Parent:
0:97b4f9625db2
ENCORDER

Who changed what in which revision?

UserRevisionLine numberNew contents of line
ooseausername 0:97b4f9625db2 1 #include "mbed.h"
ooseausername 0:97b4f9625db2 2
ooseausername 1:836ed9afcb8a 3 int main()
ooseausername 1:836ed9afcb8a 4 {
ooseausername 0:97b4f9625db2 5 mypwm.period_ms(10);
ooseausername 1:836ed9afcb8a 6 mypwm.pulsewidth_ms(1);
ooseausername 0:97b4f9625db2 7 }
ooseausername 1:836ed9afcb8a 8
ooseausername 0:97b4f9625db2 9 void _ISR _U2RXInterrupt(void)
ooseausername 0:97b4f9625db2 10 {
ooseausername 0:97b4f9625db2 11 static char Temp;
ooseausername 0:97b4f9625db2 12 Temp=U2RXREG;
ooseausername 0:97b4f9625db2 13 if (Receive_Flag==1)
ooseausername 0:97b4f9625db2 14 {
ooseausername 0:97b4f9625db2 15 Receive_Counter++;
ooseausername 0:97b4f9625db2 16 Receive_Data[Receive_Counter]=Temp;
ooseausername 0:97b4f9625db2 17
ooseausername 0:97b4f9625db2 18 if(Receive_Counter==9)
ooseausername 0:97b4f9625db2 19 {
ooseausername 0:97b4f9625db2 20 Command_Flag=1;
ooseausername 0:97b4f9625db2 21 Receive_Flag=0;
ooseausername 0:97b4f9625db2 22 Receive_Counter=0;
ooseausername 0:97b4f9625db2 23 }
ooseausername 0:97b4f9625db2 24 }
ooseausername 0:97b4f9625db2 25 else
ooseausername 0:97b4f9625db2 26 {
ooseausername 0:97b4f9625db2 27 if(Temp==36)
ooseausername 0:97b4f9625db2 28 {
ooseausername 0:97b4f9625db2 29 Receive_Flag=1;
ooseausername 0:97b4f9625db2 30 Receive_Counter=0;
ooseausername 0:97b4f9625db2 31 Receive_Data[0]= Temp;
ooseausername 0:97b4f9625db2 32 }
ooseausername 0:97b4f9625db2 33 else
ooseausername 1:836ed9afcb8a 34 {}
ooseausername 0:97b4f9625db2 35 }
ooseausername 0:97b4f9625db2 36 IFS1bits.U2RXIF=0;
ooseausername 0:97b4f9625db2 37 }
ooseausername 0:97b4f9625db2 38
ooseausername 0:97b4f9625db2 39
ooseausername 0:97b4f9625db2 40 if(Command_Flag==1)
ooseausername 0:97b4f9625db2 41 {
ooseausername 0:97b4f9625db2 42 Position_Error=(Receive_Data[2]-0x30)*100+(Receive_Data[3]-0x30)*10+(Receive_Data[4]-0x30);
ooseausername 0:97b4f9625db2 43
ooseausername 0:97b4f9625db2 44 if(Receive_Data[1]=='-')
ooseausername 0:97b4f9625db2 45 Position_Error=-1*Position_Error;
ooseausername 0:97b4f9625db2 46 else Position_Error=Position_Error;
ooseausername 0:97b4f9625db2 47
ooseausername 0:97b4f9625db2 48 Degree_Error=(Receive_Data[6]-0x30)*100+(Receive_Data[7]-0x30)*10+(Receive_Data[8]-0x30);
ooseausername 0:97b4f9625db2 49
ooseausername 0:97b4f9625db2 50 if(Receive_Data[5]=='-')
ooseausername 0:97b4f9625db2 51 Degree_Error=-1*Degree_Error;
ooseausername 0:97b4f9625db2 52 else Degree_Error=Degree_Error;
ooseausername 0:97b4f9625db2 53 if(Receive_Data[9]=='j') pwm_duty=148;
ooseausername 0:97b4f9625db2 54 else if (Receive_Data[9]=='k') pwm_duty=100;
ooseausername 0:97b4f9625db2 55 Command_Flag=0;
ooseausername 0:97b4f9625db2 56 }