PWM sine wave manipulation by the arduino motor shield

Hi, I will start with what I am trying to do, then explain my problem.

I want to generate an amplified sine wave that oscillates about 0v. I am using an arduino micro and an arduino motor shield. The micro is outputting a PWM generated sine wave that plots only positive values (see A in attached), this is fed into the motor shield. After each period the code calls for the motor direction to be changed, my thinking is that this will give me the sine wave output I want, and it does (in a way).

A is the output (measured using the oscilloscope) from the arduino PWM pin. This PWM signal is fed into the motor shield and the resulting output is B. So it has been amplified and has a similar form but the range has been reduced to 6v-8v. When you add the directional flip element to the code the get C, which seems to be the same shape as B but with a voltage flip each period as expected.

Any advice on what is going on here would be much appreciated. The motor shield input voltage is 9v, my code is below.


const int PIN = 3;
int dir = 255;

void setup()
{
digitalWrite(9, LOW);
}

void loop()
{
analogWrite(12, dir);
float in, out;

for (in = 0; in < 180; in = in + 1)
{
out = sin(radians(in)) * 255;
analogWrite(PIN, out);
delay(1);
}

if (dir == 255)
{
dir = 0;
}
else
{
dir = 255;
}

}

How is the bridge being PWM'd? If PWM is only applied to one switch you won't
get linear response to the duty-cycle, synchronous switching of both high and low
switches is needed.