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 CFGWORD2 not implemented

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



Joined: 28 May 2018
Posts: 3

View user's profile Send private message

pic16f877a CFGWORD2 not implemented
PostPosted: Mon May 28, 2018 4:23 pm     Reply with quote

this is the code
Code:

//LCD module connections
#define LCD_RS_PIN PIN_D0
#define LCD_RW_PIN PIN_D1
#define LCD_ENABLE_PIN PIN_D2
#define LCD_DATA4 PIN_D3
#define LCD_DATA5 PIN_D4
#define LCD_DATA6 PIN_D5
#define LCD_DATA7 PIN_D6
//End LCD module connections

#include <16F887.h>
#fuses NOMCLR NOBROWNOUT NOLVP INTRC_IO
#use delay(clock = 8MHz)
#include <lcd.c>

short nec_ok = 0;
unsigned int8 nec_state = 0, command, inv_command, i;
unsigned int16 address;
unsigned int32 nec_code;
#INT_EXT                                         // External interrupt
void ext_isr(void){
  unsigned int16 time;
  if(nec_state != 0){
    time = get_timer1();                         // Store Timer1 value
    set_timer1(0);                               // Reset Timer1
  }
  switch(nec_state){
    case 0 :                                     // Start receiving IR data (we're at the beginning of 9ms pulse)
      setup_timer_1( T1_INTERNAL | T1_DIV_BY_2 );   // Enable Timer1 module with internal clock source and prescaler = 2
      set_timer1(0);                             // Reset Timer1 value
      nec_state = 1;                             // Next state: end of 9ms pulse (start of 4.5ms space)
      i = 0;
      ext_int_edge( H_TO_L );                    // Toggle external interrupt edge
      return;
    case 1 :                                     // End of 9ms pulse
      if((time > 9500) || (time < 8500)){        // Invalid interval ==> stop decoding and reset
        nec_state = 0;                           // Reset decoding process
        setup_timer_1(T1_DISABLED);              // Stop Timer1 module
      }
      else
        nec_state = 2;                           // Next state: end of 4.5ms space (start of 562µs pulse)
      ext_int_edge( L_TO_H );                    // Toggle external interrupt edge
      return;
    case 2 :                                     // End of 4.5ms space
      if((time > 5000) || (time < 4000)){        // Invalid interval ==> stop decoding and reset
        nec_state = 0;                           // Reset decoding process
        setup_timer_1(T1_DISABLED);              // Stop Timer1 module
        return;
      }
      nec_state = 3;                             // Next state: end of 562µs pulse (start of 562µs or 1687µs space)
      ext_int_edge( H_TO_L );                    // Toggle external interrupt edge
      return;
    case 3 :                                     // End of 562µs pulse
      if((time > 700) || (time < 400)){          // Invalid interval ==> stop decoding and reset
        nec_state = 0;                           // Reset decoding process
        setup_timer_1(T1_DISABLED);              // Disable Timer1 module
      }
      else
        nec_state = 4;                           // Next state: end of 562µs or 1687µs space
      ext_int_edge( L_TO_H );                    // Toggle external interrupt edge
      return;
    case 4 :                                     // End of 562µs or 1687µs space
      if((time > 1800) || (time < 400)){         // Invalid interval ==> stop decoding and reset
        nec_state = 0;                           // Reset decoding process
        setup_timer_1(T1_DISABLED);              // Disable Timer1 module
        return;
      }
      if( time > 1000)                           // If space width > 1ms (short space)
        bit_set(nec_code, (31 - i));             // Write 1 to bit (31 - i)
      else                                       // If space width < 1ms (long space)
        bit_clear(nec_code, (31 - i));           // Write 0 to bit (31 - i)
      i++;
      if(i > 31){                                // If all bits are received
        nec_ok = 1;                              // Decoding process OK
        disable_interrupts(INT_EXT);             // Disable the external interrupt
      }
      nec_state = 3;                             // Next state: end of 562µs pulse (start of 562µs or 1687µs space)
      ext_int_edge( H_TO_L );                    // Toggle external interrupt edge
  }
}
#INT_TIMER1                                      // Timer1 interrupt (used for time out)
void timer1_isr(void){
  nec_state = 0;                                 // Reset decoding process
  ext_int_edge( L_TO_H );                        // External interrupt edge from high to low
  setup_timer_1(T1_DISABLED);                    // Disable Timer1 module
  clear_interrupt(INT_TIMER1);                   // Clear Timer1 interrupt flag bit
}
void main(){
  setup_oscillator(OSC_8MHZ);                    // Set internal oscillator to 8MHz
  set_tris_b(0x01);
    set_tris_d(0x00);
  lcd_init();                                    // Initialize LCD module
  lcd_putc('\f');                                // LCD clear
  enable_interrupts(GLOBAL);                     // Enable global interrupts
  enable_interrupts(INT_EXT_L2H);                // Enable external interrupt
  clear_interrupt(INT_TIMER1);                   // Clear Timer1 interrupt flag bit
  enable_interrupts(INT_TIMER1);                 // Enable Timer1 interrupt
  lcd_gotoxy(1, 1);
  printf(lcd_putc, "Address:0x0000");
  lcd_gotoxy(1, 2);                              // Go to column 1 line 2
  printf(lcd_putc, "Com:0x00 In:0x00");
  while(TRUE){
    if(nec_ok){                                  // If the mcu successfully receives NEC protocol message
      nec_ok = 0;                                // Reset decoding process
      nec_state = 0;
      setup_timer_1(T1_DISABLED);                // Disable Timer1 module
      address = nec_code >> 16;
      command = nec_code >> 8;
      inv_command = nec_code;
      lcd_gotoxy(11, 1);                         // Go to column 11 line 1
      printf(lcd_putc,"%4LX",address);
      lcd_gotoxy(7, 2);                          // Go to column 7 line 2
      printf(lcd_putc,"%2X",command);
      lcd_gotoxy(15, 2);                         // Go to column 15 line 2
      printf(lcd_putc,"%2X",inv_command);
      enable_interrupts(INT_EXT_H2L);            // Enable external interrupt
    }
  }
}


when i start the simulation in proteus i get this error list

Code:
PROSPICE 8.02.00 (Build 18620) (C) Labcenter Electronics 1993-2015.
Loaded netlist 'C:\Users\wahab\AppData\Local\Temp\LISA4057.SDF' for design '6 KANAL.pdsprj'
PIC16 model release 8.03.00 (Build 19892) simulating PIC1684 device. [U1]
PIC16 model release 8.03.00 (Build 19892) simulating PIC1684 device. [U2]
PIC16 model release 8.03.00 (Build 19892) simulating PIC168771 device. [U3]
Loaded 64 bytes of persistent EEPROM data. [U1]
[COFF] Loading PIC COFF file 'D:\pic\rf remote pic16f84a\rf_remote_pic16f84a.COF'. [U1]
END Of BOOTING [U1]
Loaded 277 program words and 0 data bytes. [U1]
Loaded 64 bytes of persistent EEPROM data. [U2]
[COFF] Loading PIC COFF file 'D:\pic\rf remote pic16f84a\reciver\ir modified\rf_remote_pic16f84a.COF'. [U2]
END Of BOOTING [U2]
Loaded 280 program words and 0 data bytes. [U2]
Loaded 256 bytes of persistent EEPROM data. [U3]
[COFF] Loading PIC COFF file 'D:\pic\rf remote pic16f84a\reciver\interrupt and timer0  pic16f877a\16f877a_nec_decoder.COF'. [U3]
CFGWORD2 not implemented [U3]
END Of BOOTING [U3]
Loaded 894 program words and 0 data bytes. [U3]
[PIC16 MEMORY] PC=0x0311. Attempt to write unimplemented memory location 0x008F with 0x71 ignored. [U3]
[PIC16 MEMORY] PC=0x0312. Attempt to read unimplemented memory location 0x008F ignored. [U3]
[PIC16 MEMORY] PC=0x0318. Attempt to read unimplemented memory location 0x0189 ignored. [U3]
[PIC16 MEMORY] PC=0x031A. Attempt to write unimplemented memory location 0x0189 with 0x00 ignored. [U3]
[PIC16 MEMORY] PC=0x0320. Attempt to write unimplemented memory location 0x0188 with 0x00 ignored. [U3]
[PIC16 MEMORY] PC=0x0322. Attempt to write unimplemented memory location 0x0107 with 0x00 ignored. [U3]
[PIC16 MEMORY] PC=0x0323. Attempt to write unimplemented memory location 0x0108 with 0x00 ignored. [U3]
[PIC16 MEMORY] PC=0x0324. Attempt to write unimplemented memory location 0x0109 with 0x00 ignored. [U3]
[PIC16 MEMORY] PC=0x0329. Attempt to write unimplemented memory location 0x008F with 0x71 ignored. [U3]
[PIC16 MEMORY] PC=0x032A. Attempt to read unimplemented memory location 0x008F ignored. [U3]
[PIC16] PC=0x0354. Processor has been reset by watchdog timer expiring at time 2.304000. [U3]
[PIC16 MEMORY] PC=0x0311. Attempt to write unimplemented memory location 0x008F with 0x71 ignored. [U3]
[PIC16 MEMORY] PC=0x0312. Attempt to read unimplemented memory location 0x008F ignored. [U3]
[PIC16 MEMORY] PC=0x0318. Attempt to read unimplemented memory location 0x0189 ignored. [U3]
[PIC16 MEMORY] PC=0x031A. Attempt to write unimplemented memory location 0x0189 with 0x00 ignored. [U3]
[PIC16 MEMORY] PC=0x0320. Attempt to write unimplemented memory location 0x0188 with 0x00 ignored. [U3]
[PIC16 MEMORY] PC=0x0322. Attempt to write unimplemented memory location 0x0107 with 0x00 ignored. [U3]
[PIC16 MEMORY] PC=0x0323. Attempt to write unimplemented memory location 0x0108 with 0x00 ignored. [U3]
[PIC16 MEMORY] PC=0x0324. Attempt to write unimplemented memory location 0x0109 with 0x00 ignored. [U3]
[PIC16 MEMORY] PC=0x0329. Attempt to write unimplemented memory location 0x008F with 0x71 ignored. [U3]
[PIC16 MEMORY] PC=0x032A. Attempt to read unimplemented memory location 0x008F ignored. [U3]
[PIC16] PC=0x0354. Processor has been reset by watchdog timer expiring at time 4.608000. [U3]
[PIC16 MEMORY] PC=0x0311. Attempt to write unimplemented memory location 0x008F with 0x71 ignored. [U3]
[PIC16 MEMORY] PC=0x0312. Attempt to read unimplemented memory location 0x008F ignored. [U3]
[PIC16 MEMORY] PC=0x0318. Attempt to read unimplemented memory location 0x0189 ignored. [U3]
[PIC16 MEMORY] PC=0x031A. Attempt to write unimplemented memory location 0x0189 with 0x00 ignored. [U3]
[PIC16 MEMORY] PC=0x0320. Attempt to write unimplemented memory location 0x0188 with 0x00 ignored. [U3]
[PIC16 MEMORY] PC=0x0322. Attempt to write unimplemented memory location 0x0107 with 0x00 ignored. [U3]
[PIC16 MEMORY] PC=0x0323. Attempt to write unimplemented memory location 0x0108 with 0x00 ignored. [U3]
[PIC16 MEMORY] PC=0x0324. Attempt to write unimplemented memory location 0x0109 with 0x00 ignored. [U3]
[PIC16 MEMORY] PC=0x0329. Attempt to write unimplemented memory location 0x008F with 0x71 ignored. [U3]
[PIC16 MEMORY] PC=0x032A. Attempt to read unimplemented memory location 0x008F ignored. [U3]
[PIC16] PC=0x0354. Processor has been reset by watchdog timer expiring at time 6.912000. [U3]
[PIC16 MEMORY] PC=0x0311. Attempt to write unimplemented memory location 0x008F with 0x71 ignored. [U3]
[PIC16 MEMORY] PC=0x0312. Attempt to read unimplemented memory location 0x008F ignored. [U3]
[PIC16 MEMORY] PC=0x0318. Attempt to read unimplemented memory location 0x0189 ignored. [U3]
[PIC16 MEMORY] PC=0x031A. Attempt to write unimplemented memory location 0x0189 with 0x00 ignored. [U3]
[PIC16 MEMORY] PC=0x0320. Attempt to write unimplemented memory location 0x0188 with 0x00 ignored. [U3]
[PIC16 MEMORY] PC=0x0322. Attempt to write unimplemented memory location 0x0107 with 0x00 ignored. [U3]
[PIC16 MEMORY] PC=0x0323. Attempt to write unimplemented memory location 0x0108 with 0x00 ignored. [U3]
[PIC16 MEMORY] PC=0x0324. Attempt to write unimplemented memory location 0x0109 with 0x00 ignored. [U3]
[PIC16 MEMORY] PC=0x0329. Attempt to write unimplemented memory location 0x008F with 0x71 ignored. [U3]
[PIC16 MEMORY] PC=0x032A. Attempt to read unimplemented memory location 0x008F ignored. [U3]
[PIC16] PC=0x0354. Processor has been reset by watchdog timer expiring at time 9.216000. [U3]
[PIC16 MEMORY] PC=0x0311. Attempt to write unimplemented memory location 0x008F with 0x71 ignored. [U3]
[PIC16 MEMORY] PC=0x0312. Attempt to read unimplemented memory location 0x008F ignored. [U3]
[PIC16 MEMORY] PC=0x0318. Attempt to read unimplemented memory location 0x0189 ignored. [U3]
[PIC16 MEMORY] PC=0x031A. Attempt to write unimplemented memory location 0x0189 with 0x00 ignored. [U3]
[PIC16 MEMORY] PC=0x0320. Attempt to write unimplemented memory location 0x0188 with 0x00 ignored. [U3]
[PIC16 MEMORY] PC=0x0322. Attempt to write unimplemented memory location 0x0107 with 0x00 ignored. [U3]
[PIC16 MEMORY] PC=0x0323. Attempt to write unimplemented memory location 0x0108 with 0x00 ignored. [U3]
[PIC16 MEMORY] PC=0x0324. Attempt to write unimplemented memory location 0x0109 with 0x00 ignored. [U3]
[PIC16 MEMORY] PC=0x0329. Attempt to write unimplemented memory location 0x008F with 0x71 ignored. [U3]
[PIC16 MEMORY] PC=0x032A. Attempt to read unimplemented memory location 0x008F ignored. [U3]
[PIC16] PC=0x0354. Processor has been reset by watchdog timer expiring at time 11.520000. [U3]
[PIC16 MEMORY] PC=0x0311. Attempt to write unimplemented memory location 0x008F with 0x71 ignored. [U3]
[PIC16 MEMORY] PC=0x0312. Attempt to read unimplemented memory location 0x008F ignored. [U3]
[PIC16 MEMORY] PC=0x0318. Attempt to read unimplemented memory location 0x0189 ignored. [U3]
[PIC16 MEMORY] PC=0x031A. Attempt to write unimplemented memory location 0x0189 with 0x00 ignored. [U3]
[PIC16 MEMORY] PC=0x0320. Attempt to write unimplemented memory location 0x0188 with 0x00 ignored. [U3]
[PIC16 MEMORY] PC=0x0322. Attempt to write unimplemented memory location 0x0107 with 0x00 ignored. [U3]
[PIC16 MEMORY] PC=0x0323. Attempt to write unimplemented memory location 0x0108 with 0x00 ignored. [U3]
[PIC16 MEMORY] PC=0x0324. Attempt to write unimplemented memory location 0x0109 with 0x00 ignored. [U3]
[PIC16 MEMORY] PC=0x0329. Attempt to write unimplemented memory location 0x008F with 0x71 ignored. [U3]
[PIC16 MEMORY] PC=0x032A. Attempt to read unimplemented memory location 0x008F ignored. [U3]
[PIC16] PC=0x0354. Processor has been reset by watchdog timer expiring at time 13.824000. [U3]
[PIC16 MEMORY] PC=0x0311. Attempt to write unimplemented memory location 0x008F with 0x71 ignored. [U3]
[PIC16 MEMORY] PC=0x0312. Attempt to read unimplemented memory location 0x008F ignored. [U3]
[PIC16 MEMORY] PC=0x0318. Attempt to read unimplemented memory location 0x0189 ignored. [U3]
[PIC16 MEMORY] PC=0x031A. Attempt to write unimplemented memory location 0x0189 with 0x00 ignored. [U3]
[PIC16 MEMORY] PC=0x0320. Attempt to write unimplemented memory location 0x0188 with 0x00 ignored. [U3]
[PIC16 MEMORY] PC=0x0322. Attempt to write unimplemented memory location 0x0107 with 0x00 ignored. [U3]
[PIC16 MEMORY] PC=0x0323. Attempt to write unimplemented memory location 0x0108 with 0x00 ignored. [U3]
[PIC16 MEMORY] PC=0x0324. Attempt to write unimplemented memory location 0x0109 with 0x00 ignored. [U3]
[PIC16 MEMORY] PC=0x0329. Attempt to write unimplemented memory location 0x008F with 0x71 ignored. [U3]
[PIC16 MEMORY] PC=0x032A. Attempt to read unimplemented memory location 0x008F ignored. [U3]



Thanks in advance to help solve this problem.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon May 28, 2018 5:28 pm     Reply with quote

Your title says this:
Quote:
pic16f877a CFGWORD2 not implemented

But your code says this:
Quote:
#include <16F887.h>

So which is it ? Those are two different PICs.
temtronic



Joined: 01 Jul 2010
Posts: 9245
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Mon May 28, 2018 5:34 pm     Reply with quote

get rid of Proteus !!!
please read PIC101

this...
PIC16 model release 8.03.00 (Build 19892) simulating PIC1684 device. [U1]
PIC16 model release 8.03.00 (Build 19892) simulating PIC1684 device. [U2]
PIC16 model release 8.03.00 (Build 19892) simulating PIC168771 device. [U3]
Loaded 64 bytes of persistent EEPROM data. [U1]
[COFF] Loading PIC COFF file 'D:\pic\rf remote pic16f84a\rf_remote_pic16f84a.COF'. [U1]

appears to ONLY simulate 2 devices, neither is your device...
so I'll assume your version of Proteus is NOT capable of simulating the PIC you're trying to use, well test.
electrobaiker



Joined: 28 May 2018
Posts: 3

View user's profile Send private message

PostPosted: Mon May 28, 2018 5:51 pm     Reply with quote

I changed #include <16F887.h> to #include <16F877a.h>

The problem now is I can't get 1us delay in Timer1.

Using this prescaler config
Code:
  setup_timer_1( T1_INTERNAL | T1_DIV_BY_2 );


What is wrong please ?
temtronic



Joined: 01 Jul 2010
Posts: 9245
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Mon May 28, 2018 6:17 pm     Reply with quote

well I counted 5 or 6 lines where you disabled timer1( including inside the ISR) and nowhere you enable it after the first 'initialization' code..
the code seems correct
8MHz Fosc/4= 2 MHz then /2 give 1MHz which is 1us...
electrobaiker



Joined: 28 May 2018
Posts: 3

View user's profile Send private message

PostPosted: Mon May 28, 2018 6:56 pm     Reply with quote

Yes now it work properly. The problem with Timer1 delay come from i miss to set pic frequency in proteus to 8 MHz, by default it is 1 MHz.
Thanks for your support.
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