[SOLVED] Can not activate portc pin

Status
Not open for further replies.

cutu

Newbie level 6
Joined
Dec 24, 2012
Messages
12
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Visit site
Activity points
1,363
mikrokontroler pic 16f887

code:
Code:
 void main(){
       trisc=0;
       portc=0;
       while(1){
             if (some bit){
                for (condition){
                    rc3_bit=1;
                    delay;
                        rc3_bit=0;
                        delay;
                    }}}}

This code is not vorking. If I put (portc instade of rc3_bit) code works fine.I use mikroC.
It also makes mi problems when I use interrupt
Can some one explane it to me.


thanks
 
Last edited by a moderator:

PORTC is 8 bits. RC3 is 4th bit of PORTC. You can use PORTC.F3 or PORTC.B3 instead of RC3_bit. A better place to ask you question is mikroe forum. Post your code and we will try to help with your interrupt problem.
 
Reactions: cutu

    cutu

    Points: 2
    Helpful Answer Positive Rating
ok. thanks. I did not try as PORTC.F3,B3. I tryed as portc.rc3 but it did not work.
 

Code:
unsigned int w;
void main(){
trisa=255;
porta=255;
trisb=0;
portb=0;
while(1){
if(ra0_bit!=1){
for(i=0;i<w;i++)
portc=255;
delay_ms(10);
portc=0;
delay_ms(10);
}}}

I want to make puls output only on portc.rc3 pin.
I do not want to do it over pwm.
leater I wont to use tmr2 interrupt to make more Hz

- - - Updated - - -

I made error writing code
Code:
trisc=0;
portc=0;
 
Last edited by a moderator:

Code:
unsigned int w;
void main(){
trisa=255;
porta=255;
trisb=0;
portb=0;
while(1){
if(ra0_bit!=1){
for(i=0;i<w;i++)
portc=255;
delay_ms(10);
portc=0;
delay_ms(10);
}}}
 

I think you are using PORTA as input port and PORTC as output port. So, you should replace
Code:
 trisb=0;
portb=0;
by
Code:
 trisc=0;
portc=0;
and replace
Code:
 ra0_bit!=1
by
Code:
 PORTA.F0 != 1

and if you are using LED as the output then 10ms delay is less and you cannot see the blinking of LED. Make delay 500 ms.

Have you initialized w? What is the value of w?
 

Which controller are you using?
Blinking led on RC3 pin. connect led to PIN C3. Check led blinks.
HTML:
 sbit LED at RC3_bit;
void main() {
ANSEL = 0b00000000; //All I/O pins are configured as digital
CMCON0 = 0×07 ; // Disable comparators
TRISC = 0b00000000; // PORTC All Outputs

do {
LED = 1;
Delay_ms(1000);
LED = 0;
Delay_ms(1000);
} while(1);  // Infinite Loop
}
 

the port is defined corectli.
I solwed the problem.
code works.
If you define onliy that pin with(trisc.rc3=1) you will have output.
I im controling steper drive and motor like this
 

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…