CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

PIC16F877A int_ext

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Khansokhua



Joined: 06 Nov 2021
Posts: 92

View user's profile Send private message

PIC16F877A int_ext
PostPosted: Sat Nov 27, 2021 4:07 am     Reply with quote

Code:
#include <Timerlar.h>
#fuses XT
#use delay(clock=4M)
#use fast_io(b)
int i;
const int segment[10]= {0x3F,0x06,0x5B,0x4F,0x66,0x6D,0x7C,0x07,0x7F,0x6F};

#int_ext
void ext_kesme()
{
   output_high(pin_d0);
   delay_ms(1000);
   output_low(pin_d0);
   delay_ms(3000);
   
   for(i=0;i<=9;i++)
   {   
        output_c(segment[i]);
        output_high(pin_d0);
        delay_ms(500);
        output_low(pin_d0);
        delay_ms(500);   
   }

}


void main()
{   
  set_tris_b(0x01);
   
   output_c(0x00);
   output_d(0x00);   
   output_a(0x02);
 
     
   ext_int_edge(L_TO_H);
   
   enable_interrupts(int_ext);
   enable_interrupts(GLOBAL);
}

Hi greetings! I don't know why, how on PORTB RB2-RB3-RB5-RB6 were being logic "1". I just wonder why this happened ?
If someone could explain, thanks respects!
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

Re: PIC16F877A int_ext
PostPosted: Sat Nov 27, 2021 9:29 am     Reply with quote

Khansokhua wrote:

output_c(0x00);
output_d(0x00);
output_a(0x02);

I don't know why, how on PORTB RB2-RB3-RB5-RB6 were being logic "1".

You never initialize PortB. You only initialize ports C, D, and A.
If you want PortB to be 0x00, then add this line:
Code:
output_b(0x00);
Ttelmah



Joined: 11 Mar 2010
Posts: 19553

View user's profile Send private message

PostPosted: Sat Nov 27, 2021 12:20 pm     Reply with quote

The point is you set the TRIS:

set_tris_b(0x01);

Now the register for a port defaults to '1' (data sheet), so when you set
the tris to set these bits as outputs all the bits (except B1), go high.
To set the bits to low, and leave B1 as an input - get rid of the above
TRIS instruction, then:
Code:

   output_b(0); //B0 to B7 now all 0
   output_float(PIN_B1); //B1 is now an input
Khansokhua



Joined: 06 Nov 2021
Posts: 92

View user's profile Send private message

PostPosted: Mon Nov 29, 2021 4:10 am     Reply with quote

Thank you
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group