Robotic_winteam / Mbed 2 deprecated Nucleo_pwmdecoder

Dependencies:   mbed

main.cpp

Committer:
ooseausername
Date:
2016-05-25
Revision:
1:836ed9afcb8a
Parent:
0:97b4f9625db2

File content as of revision 1:836ed9afcb8a:

#include "mbed.h"

int main() 
    {
    mypwm.period_ms(10);
    mypwm.pulsewidth_ms(1);  
    }

void _ISR _U2RXInterrupt(void)
{
static char Temp;
Temp=U2RXREG;
if (Receive_Flag==1)
{
Receive_Counter++;
Receive_Data[Receive_Counter]=Temp;

if(Receive_Counter==9)
{
Command_Flag=1;
Receive_Flag=0;
Receive_Counter=0;
}
}
else
{
if(Temp==36)
{
Receive_Flag=1;
Receive_Counter=0;
Receive_Data[0]= Temp;
}
else
{}
}
IFS1bits.U2RXIF=0;
}


if(Command_Flag==1)
{
Position_Error=(Receive_Data[2]-0x30)*100+(Receive_Data[3]-0x30)*10+(Receive_Data[4]-0x30);

if(Receive_Data[1]=='-')
Position_Error=-1*Position_Error;
else Position_Error=Position_Error; 

Degree_Error=(Receive_Data[6]-0x30)*100+(Receive_Data[7]-0x30)*10+(Receive_Data[8]-0x30);

if(Receive_Data[5]=='-')
Degree_Error=-1*Degree_Error;
else Degree_Error=Degree_Error;
if(Receive_Data[9]=='j') pwm_duty=148;
else if (Receive_Data[9]=='k') pwm_duty=100;
Command_Flag=0;
}