Hey Guys,
im trying 2 generate a pwm signal to drive a stepper motor, got hold of Mitsubishi's example code which goes like this...
#include "sfr62.h"
void main(void); void initPorts(void);
void initPorts(void) { pd0 = 0xFF; // output mode pd1 = 0xFF; // output mode pu00 = 0; // no pull up for P0_0 to P0_3 pu01 = 0; // no pull up for P0_4 to P0_7 pu02 = 0; // no pull up for P1_0 to P1_3 p1 = 0xFF; // disable LED1 and LED2 p0 = 0xFF; // turn off all segments
pd7 = 0XFF; // set port P7 to output mode pu16 = 0; // no pull up for P7_0 to P7_3 , P7_0 & P7_1 needs a pull-up pu17 = 0; // no pull up for P7_4 to P7_7 p7 = 0XFF; // initial port P7 data }
void main(void) { initPorts(); ta1mr = 0X27; //set timerA1 to 8bit PWM mode ta1 = 0X0102; //set pwm cycle to 50us tabsr = 0x02; //start the timerA1 }
Now using this code i get a signal on my pin p7.2 which is nearly 50us but i dont understand the initports function.....it changes port 0,1 and 7 to o/p mode thats ok but what is up with the "pull up" part makes no sense. For the sake of understanding i changed all the settings to port2 from port7 but that has made no difference i still get a signal at p7.2
ny help appreciated thanks Nav