CCS 16f84a Kesme Çalışmıyor eksik olan nedir?

Başlatan GreeN, 15 Haziran 2009, 12:53:26

GreeN

Arkadaşlar CCS pic c ile çalışmaya yeni başladım. (PIC e de yabancıyım)

Basit bir deneme yapmak istedim. External interrupt ile LCD ye bir veri yazdırmak istiyorum.
B0 a bir buton +5v bağlı.  (l_to_h)
Acaba #define use_portb_lcd TRUE bu satır yüzündenmi B0'ı kullanamıyorum.
kod;

#include <16f84a.h>
#fuses HS,noWDT,NOPROTECT,PUT
#use delay (clock=4000000)
#define use_portb_lcd TRUE
#include <lcd.c>
// enable b1 rs b2 rw b3
// b0 interrupt için

#int_ext
void  EXT_isr(void)
{
 lcd_putc("\f 111111...\n");
} 

void main() {
long say;
   
   ext_int_edge( l_to_h );
   enable_interrupts(global);
   enable_interrupts(int_ext); 
   lcd_init();
   lcd_putc("\fHAZIR\n");
   
}
Terörü Lanetliyoruz.

MURSEL

Acaba #define use_portb_lcd TRUE bu satır yüzündenmi B0'ı kullanamıyorum.



kullandıralım
lcd.c dosyasının içindeki  
struct lcd_pin_map {                 // This structure is overlayed
           BOOLEAN enable;           // on to an I/O port to gain
           BOOLEAN rs;               // access to the LCD pins.
           BOOLEAN rw;               // The bits are allocated from
           BOOLEAN unused;           // low order up.  ENABLE will
           int     data : 4;         // be pin B0.
        } lcd;


alttaki ile degiştirsen
struct lcd_pin_map {  
           BOOLEAN unused;                // This structure is       overlayed                     // on to an I/O port to gain
           BOOLEAN rs;               // access to the LCD pins.
           BOOLEAN rw; 
           BOOLEAN enable; // The bits are allocated from
           int     data : 4;         // be pin B0.
        } lcd;


suan b0 pinin boşta  b1=rs ,b2=rw b3=enable diger pinler data

bu sekilde çözüm olucagını düşünüyorum

GreeN

struct lcd_pin_map {                 // This structure is overlayed
           BOOLEAN unused;           // on to an I/O port to gain
           BOOLEAN enable;               // access to the LCD pins.
           BOOLEAN rs;               // The bits are allocated from
           BOOLEAN rw ;          // low order up.  ENABLE will
           int     data : 4;         // be pin B0.
        } lcd;



Bu şekilde değiştirdim. LCD çalışıyor. HAZIR mesajı geliyor. Ama butona bastığımda "11111...." mesajı gelmiyor sanki kesme çalışmıyor gibi.
Terörü Lanetliyoruz.

MURSEL

yine lcd.c dosyasında
struct lcd_pin_map const LCD_WRITE = {0,0,0,0,0}; // For write mode all pins are out
struct lcd_pin_map const LCD_READ = {0,0,0,0,15}; // For read mode data pins are in


yerine

struct lcd_pin_map const LCD_WRITE = {1,0,0,0,0}; // For write mode all pins are out
struct lcd_pin_map const LCD_READ = {1,0,0,0,15}; // For read mode data pins are in


yazıp tekrar denermisin  farkettigin  gibi 0 yerine 1 koydum pin b0 giriş için
nerden cıkardın bunu diyebilirsin  

lcd.c driverin içinde

  #define set_tris_lcd(x) set_tris_b(x)
set_tris_lcd(LCD_WRITE);
  set_tris_lcd(LCD_READ);

her lcd ye yazı yazdırdıgında bu komutlarıda kullanmış oluyorsun



#include <16f84a.h> 
#fuses HS,noWDT,NOPROTECT,PUT 
#use delay (clock=4000000) 
#define use_portb_lcd TRUE 
#include "lcd.c" 
// enable b1 rs b2 rw b3 
// b0 interrupt için 

#int_ext 
void  EXT_isr(void) 
{ 
 lcd_putc("\f 111111...\n"); 
} 

void main() { 
long say; 
    set_tris_b(0x01);
   ext_int_edge( l_to_h ); 
   enable_interrupts(global); 
   enable_interrupts(int_ext); 
   lcd_init(); 
   while(1)
   {
   lcd_putc("\fHAZIR\n");
   delay_ms(1000);
   }
    
}
 bu şekilde denedim calışıyor

GreeN

MURSEL çok teşekkür ederim. Sonunda oldu.
Terörü Lanetliyoruz.