Programming electric pulses (FES)

I'm trying to program my 'electrotherapy' device to feature a motor(vibrate) and electric pulses(FES).

Im running on this silicon lab program, on a 8051 with a connected LCD screen for display..

This is but a small extract of the void main

while(1)
{
if(PB2==1) //switch 2
{
pls++;
if(pls==1)
{
pulse1=~pulse1;
delay(100000);
pulse2=~pulse2;
delay(100000);
}
if(pls==2)
{
pulse1=~pulse1;
delay(10);
pulse2=~pulse2;
delay(10);
}
if(pls>2)
{
pls=0;
}
while(PB2==1);
}
LCD_command(0xC2);
LCD_msg1("FES Power:");
LCD_command(0xCC);
LCD_num1(pls);
}


The LCD screen is a 16bit display
pls is a variable that i have initialized as a form of count
PB1/2 are my switches which i have initialized already
pulse1 & pulse2 has been initialized under my port 2^0 and port 2^7 on my 8051

things to note:
upon connecting to a power source, a current can felt through the electrode gel pads.
setting a logic '1'(inverted) to the pulse1 & pulse2 will create an actual electric pulse whereby it off for a period of time(depending on my delay input)

When i set the infinite while loop(while(1)), there is practically no current felt. Removing it is a nay, as i need it for displaying a message on my LCD display e.g. FES power 0,1,2,3,4,5

Hoping for someone who can enlighten me/advise me on my program.
my objective(as of now) is to set 5 different types of electric pulses (using delays) while showing the different types of pulses upon pressing a switch button

P.s. its mainly the programming part that im facing an issue, though not much related to circuit diagram on the FES part.

I could upload the entire file if needed to.
Topic archived. No new replies allowed.