M16C Micro timer pwm port



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

.



Relevant Pages

  • Re: Test a class...beginner question
    ... > void MakeTree; ... > int PushBranch; ... which is why understanding the code gives ... that with code I download if it's been available for a while, ...
    (alt.comp.lang.learn.c-cpp)
  • Re: Interview Questions
    ... understanding of design patterns (atleast they should have heard of the ... What is a pure virtual function, and why would you use it? ... class Super1: public Sub ... void DoSomething ...
    (microsoft.public.vc.mfc)
  • Re: How to transfer an address value without using pointers
    ...   return 0; ... understanding we should not try to free any memory using function ... Not (void *)"p" or anything like that. ... I have a poor understanding of C. ...
    (comp.lang.c)
  • Re: GC.Collect and Generations
    ... My understanding is... ... Higher generations are not collected such often as ... result in having object in high generations allthough they are not long ... void SmallMethod{ ...
    (microsoft.public.dotnet.framework.clr)
  • Re: void *
    ... That was my understanding of 'void *' concept. ... I'm afraid - but that can be ... etc) without the container knowing anything about its type. ...
    (comp.lang.c)