PWM : facing problem while implementing a small code on board.

Status
Not open for further replies.

shubham kumar

Member level 3
Joined
Sep 11, 2014
Messages
59
Helped
1
Reputation
2
Reaction score
1
Trophy points
8
Location
bangalore
Visit site
Activity points
511
Hi
I am using PIC18F452. I as compiler I am using "MikroC".

1) I cannot see the waveforms in this compiler (I mean I didnt find any such option to see the waveforms like that of timer and PWM module). Can you tell me some compiler or IDE that will do that.

2) I just tried to implement the following code on the board

Code:
  TRISD = 255;       PORTD = 0;                     // designate PORTD pins as output
  PORTC = 0;                                // set PORTC to 0
  TRISC = 0;                          // designate PORTC pins as output
            
  while(1)
             {
              if(RD4_bit==1) {
              Delay_ms(2000);
              RC6_bit= ~   RC6_bit ;}

              else if(RD5_bit==1) {
              Delay_ms(2000);
              RC6_bit= ~   RC6_bit ;}

              else
                 RC6_bit=1;
                }

   }

whenever I connect +5 volts to RD4_bit or RD5_bit , it is functioning fine but if i remove that then also it is behaving same. but if I connect it to ground then only it went for the "else" part.
I asked a friend he said that it takes TTL input if you don't connect anything it will take it as '1'.

Please throw some light on that.

3) Same kind of problem it is giving while implementing PWM. I have to make one input ground for making it work, just by removing the supply (+5V), it defaults takes it as '1'. (thats my conclusion, if something wrong please share with me )
 

Thanks hexreader,

1) I read about pull up and pull down resistors but I am left with one doubt that where should we use pull-up and pull-down.
Are there some best practices like use pull up at input port and pill down at output port or vice-versa or can we use anything at ant place.

2)I cannot see the waveforms in this compiler (I mean I didnt find any such option to see the waveforms like that of timer and PWM module). Can you tell me some compiler or IDE that will do that.
 

I cleared my doubts with Pull-up and Pull-down.

Please tell me the solution for this.
I cannot see the waveforms in this compiler (I mean I didnt find any such option to see the waveforms like that of timer and PWM module). Can you tell me some compiler or IDE that will do that. and that is easily available
 

Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…