Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[SOLVED] Problem in mikroC PRO for PIC coding for PIC16F688

Status
Not open for further replies.

shahbaz.ele

Advanced Member level 1
Advanced Member level 1
Joined
Aug 12, 2008
Messages
454
Helped
72
Reputation
146
Reaction score
73
Trophy points
1,308
Location
Islamabad, Pakistan
Activity points
3,669
Dear all I am facing aproblem in coding of PIC16F688
here is my code

Code:
// LCD module connections
sbit LCD_RS at RC4_bit;        
sbit LCD_EN at RC5_bit;        
sbit LCD_D4 at RC0_bit;
sbit LCD_D5 at RC1_bit;        
sbit LCD_D6 at RC2_bit;        
sbit LCD_D7 at RC3_bit;
sbit LCD_RS_Direction at TRISC4_bit;        
sbit LCD_EN_Direction at TRISC5_bit;
sbit LCD_D4_Direction at TRISC0_bit;        
sbit LCD_D5_Direction at TRISC1_bit;
sbit LCD_D6_Direction at TRISC2_bit;        
sbit LCD_D7_Direction at TRISC3_bit;
// End LCD module connections
// Back Light Switch connected to RA1
sbit BackLight at RA1_bit;
// Define Messages
char message0[] = "LCD Initialized";        
char message1[] = "Shahbaz Khan";
char message2[] = "RA4";
char message3[] = "RA5";
char message4[] = "   SCANING...   ";

// ISR for LCD Backlight
void interrupt(void){
  if (INTCON.RAIF == 1)          // Check if INTF flag is set
     {
     if (RA4 == 1)
     {
      Lcd_Cmd(_LCD_CLEAR);               // CLEAR display
      //BackLight = 1;
      Lcd_Out(1,1,message2);
      Delay_ms(5);
     }
     else if (RA5 == 1)
     {
      Lcd_Cmd(_LCD_CLEAR);               // CLEAR display
      //BackLight = 1;
      Lcd_Out(1,1,message3);
      Delay_ms(5);
     }
     else
     {
      //Lcd_Cmd(_LCD_CLEAR);               // CLEAR display
      //BackLight = 1;
      //Lcd_Out(1,1,message4);
      //Delay_ms(3);
     }//Delay_ms(10) ;
     INTCON.RAIF = 0;       // Clear interrupt flag before exiting ISR
     }
}
void main() {
  TRISC = 0x00 ;
  TRISA = 0b00111100; //  RA2, RA3, RA4, RA5 Inputs, Rest O/P's
  ANSEL =   0b00000000;
  PORTA =   0b00000000;            //  Start with Everything Low
  PORTC =   0b00000000;            //  Start with Everything Low
  CMCON0 =  0b00000111;
  Lcd_Init();                        // Initialize LCD
  Lcd_Cmd(_LCD_CLEAR);               // CLEAR display
  Lcd_Cmd(_LCD_CURSOR_OFF);          // Cursor off
  BackLight = 1;
  Lcd_Out(1,1,message0);
  Delay_ms(5);
  Lcd_Cmd(_LCD_CLEAR);               // CLEAR display
  Lcd_Out(1,1,message1);             // Write message1 in 1st row
  // Interrupt Setup
     //IOCA4 = 1;             //Input Change Enable RA4
    //IOCA5 = 1;             //Input Change Enable RA5
    IOCA = 0x30;
    INTCON.RAIF = 0;     // Clear interrupt flag prior to enable
    INTCON.RAIE = 1;     // enable Input Change interrupt
    //INTCON.INTF = 0;     // Clear interrupt flag prior to enable
    //INTCON.INTE = 1;     // enable INT interrupt
    INTCON.GIE  = 1;     // enable Global interrupts
 do {
 } while(1);
}


My first problem is that I do not know what would be name of PortA change intrrupt.
the intrrupt routine wrritten in code is External intrrupt.

Secondly I have short space for coding in ISR. how to use goto command.
Thanks in advance.

---------- Post added at 11:43 ---------- Previous post was at 11:41 ----------

in Second When I uncomment any one line written under else, it gives ROM error

---------- Post added at 12:31 ---------- Previous post was at 11:43 ----------

7 433 Not enough RAM for call stack __Lib_Delays.c
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top