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 support@ccsinfo.com

Unable to use 16F877's PIN B7

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



Joined: 06 Jan 2014
Posts: 31

View user's profile Send private message

Unable to use 16F877's PIN B7
PostPosted: Wed Jul 09, 2014 3:43 pm     Reply with quote

Hi,

I don't know why, i am unable to set high or low of 16F877's PIN B7. I think it's because i use port b for lcd. How can i use that pin. I am out of free pin:)Smile

Here is the code:

Code:


#include <main.h>

#include <benim_lcd.c>
#define LCD_Yaz        0x05
void main()
{

   setup_adc_ports(NO_ANALOGS);
   setup_adc(ADC_OFF);
   setup_spi(SPI_SS_DISABLED);
   setup_timer_0(RTCC_INTERNAL|RTCC_DIV_128);
   setup_timer_1(T1_INTERNAL | T1_DIV_BY_1);
   setup_timer_2(T2_DISABLED,0,1);
   setup_comparator(NC_NC_NC_NC);

   
   output_low(pin_b7);
   
   lcd_komut(0x01); 
   
   
   lcd_hazirla();
   delay_us(10);
   lcd_komut(0x01); 
   delay_us(10);
   
   imlec(1,1);
   printf(lcd_veri,"                ");
   imlec(2,1);
   printf(lcd_veri,"                ");
   
   enable_interrupts(INT_TIMER1);
   enable_interrupts(GLOBAL);
   
   delay_us(10);

for(;;){

     
        imlec(1,1);
        printf(lcd_veri,"Attention!      ");
       
        imlec(2,1);
        printf(lcd_veri,"CHECK CONNECTION");

        output_high(pin_b7);  // Pin B7 Does not turn HIGH stays low.

}
}


Here is the code of benim_lcd.c:

Code:
#define e   pin_b5 // LCD'nin E ucu RB5 pinine baðlý
#define rs  pin_b4 // LCD'nin RS ucu RB4 pinine baðlý

//****** LCD'ye Komut Gönderme Fonksiyonu **********
void lcd_komut(byte komut)
{
   output_b(komut>>4);     // Komutun yüksek deðerli 4 bitini gönder
   output_low(rs);          // LCD komut almak için ayarlandý
   output_high(e);          // E ucu lojik-1'den lojik-0'a çekiliyor
   output_low(e);
   delay_us(100);            // 2 msn gecikme veriliyor

   output_b(komut&0x0F);    // Komutun düþük deðerli 4 bitini gönder
   output_low(rs);          // LCD komut almak için ayarlandý
   output_high(e);           // E ucu lojik-1'den lojik-0'a çekiliyor
   output_low(e);
   delay_us(100);              // 2 msn gecikme veriliyor
}

//******* LCD'ye Veri Gönderme Fonksiyonu **********
void lcd_veri(byte veri)
{
   output_b(veri>>4);       // Verinin yüksek deðerli 4 bitini gönder
   output_high(rs);         // LCD veri almak için ayarlandý
   output_high(e);          // E ucu lojik-1'den lojik-0'a çekiliyor
   output_low(e);
   delay_us(100);             // 1 msn gecikme veriliyor

   output_b(veri&0x0F);    // Verinin düþük deðerli 4 bitini gönder
   output_high(rs);        // LCD veri almak için ayarlandý
   output_high(e);         // E ucu lojik-1'den lojik-0'a çekiliyor
   output_low(e);
   delay_us(170);            // 1 msn gecikme veriliyor
}

//******* LCD'de Ýmlec Konumlandýrma Fonksiyonu ********
void imlec(byte satir, byte sutun)
{
   if (satir==1)            // Eðer satýr deðiþkeni "1" ise
      lcd_komut(0x80|(sutun-1));

   if (satir==2)            // Eðer satýr deðiþkeni "2" ise
      lcd_komut(0x80|(0x40+(sutun-1)));
}

//********* LCD Baþlangýç Ayarlarý Fonksiyonu ******
void lcd_hazirla()
{
   lcd_komut(0x02);      // LCD'yi kullanýma hazýr hale getir, imleç                // 1.satýr 1.sütunda komutu
   lcd_komut(0x28);      //2 satýr, 4 bit iletiþim, 5x8 dot matris seçildi
   lcd_komut(0x08);      //Display kapalý,alt çizgi ve yanýp sönme yok
   lcd_komut(0x0C);      //Display açýk,imleç alt çizgi ve yanýp sönme yok
   lcd_komut(0x06);      // Her veri yazýldýðýnda imleç bir saða gitsin
   lcd_komut(0x01);      // Display sil. Ýmleç 1.satýr 1.sütunda
   delay_us(100);          // 1 msn bekle
}


How to use PIN B7 any help appreciated. Thanks.

I use CCS C 4.110
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed Jul 09, 2014 4:09 pm     Reply with quote

Quote:
output_b(komut>>4);

output_b() writes to all bits on PortB. Anything you write to pin B7
with output_high() will quickly be over-written by your lcd code that
uses output_b().
palyancodr



Joined: 06 Jan 2014
Posts: 31

View user's profile Send private message

PostPosted: Wed Jul 09, 2014 4:52 pm     Reply with quote

Thanks for informing, how can i exclude the pin b7?
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed Jul 09, 2014 5:03 pm     Reply with quote

Get rid of your LCD driver code, and use the Flex lcd driver in the CCS
Code Library forum. The Flex driver uses individual pins, and does not
use the output_b() function. This will let you control pin B7.
palyancodr



Joined: 06 Jan 2014
Posts: 31

View user's profile Send private message

PostPosted: Wed Jul 09, 2014 5:37 pm     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