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

Bug #int_ra routine family Enhanced Mid-range

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



Joined: 15 Jan 2010
Posts: 11

View user's profile Send private message

Bug #int_ra routine family Enhanced Mid-range
PostPosted: Mon Dec 17, 2012 3:48 pm     Reply with quote

Hi Guys!
At a one Russian forum, we found a problem with your compiler.

PIC12F1822 list source code
Code:
#include <12LF1822.h>
#case
#device adc=8

#FUSES NOWDT                 //No Watch Dog Timer
#FUSES HS                       //High speed Osc (> 4mhz for PCM/PCH) (>10mhz for PCD)
#FUSES NOCPD                    //No EE protection
#FUSES NOPROTECT           //Code not protected from reading
#FUSES NOMCLR                //Master Clear pin not enabled
#FUSES NOPUT                    //No Power Up Timer
#FUSES NOBROWNOUT        //No brownout reset
#FUSES INTRC_IO

#USE delay(internal=4M)
//***********************************************************************************************************************
#INT_RA
void isr_ra(void) {
}

//***********************************************************************************************************************
void main()
{
   int8 dummy;

   setup_adc_ports(NO_ANALOGS|VSS_VDD);
   setup_adc(ADC_OFF);
   setup_comparator(NC_NC);

   set_tris_a(0b00001000);
   dummy=input_a();
   clear_interrupt(INT_RA);
   enable_interrupts(INT_RA3);
   enable_interrupts(GLOBAL);

   for(;;) {
   };
}


piece of asm LST file:

Code:
.................... //***********************************************************************************************************************
.................... #INT_RA 
.................... void isr_ra(void) { 
....................   
.................... }
.................... 
.................... //***********************************************************************************************************************
001C:  BCF    0B.0
001D:  MOVLP  00
001E:  GOTO   013
.................... void main()
.................... {
001F:  CLRF   05


why the compiler is trying to clear the bit IOCIF
which is described as a datasheet Read-Only, instead to reset the bit in the register IOCAF ?

for PIC12F675/683 and more old family PIC this situation is true
but for PIC with family Enhanced Mid-range this not work, they should reset an appropriate bit in IOCAF.

This situation has been tested by the three controllers 12F1822, 16f1824, 16f1936

can comment ?

p.s. I sorry for my English
temtronic



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

View user's profile Send private message

PostPosted: Mon Dec 17, 2012 6:22 pm     Reply with quote

Which version of the compiler? CCS is very good at fixing 'bugs' , once they are reported(not here by the way) and they update the compilers very often.
They also post version and updates on their website.

hth
jay
tae



Joined: 15 Jan 2010
Posts: 11

View user's profile Send private message

PostPosted: Mon Dec 17, 2012 6:42 pm     Reply with quote

no problem, we use version 4.138
Quote:
not here by the way

and where ?
dyeatman



Joined: 06 Sep 2003
Posts: 1934
Location: Norman, OK

View user's profile Send private message

PostPosted: Mon Dec 17, 2012 6:55 pm     Reply with quote

Read the notice in the upper right corner of this web page!
_________________
Google and Forum Search are some of your best tools!!!!
bkamen



Joined: 07 Jan 2004
Posts: 1615
Location: Central Illinois, USA

View user's profile Send private message

PostPosted: Mon Dec 17, 2012 10:01 pm     Reply with quote

dyeatman wrote:
Read the notice in the upper right corner of this web page!


In fairness a sanity check is nice...

But yes -- if it's a bug, it should be reported to [email protected]

Now -- Setting a R/O bit isn't so much a bug if there are other parts that might need that because the bit is R/W.

I wouldn't call that a bug since it, by itself, doesn't break anything.

-Ben
_________________
Dazed and confused? I don't think so. Just "plain lost" will do. :D
ckielstra



Joined: 18 Mar 2004
Posts: 3680
Location: The Netherlands

View user's profile Send private message

Re: Bug #int_ra routine family Enhanced Mid-range
PostPosted: Tue Dec 18, 2012 6:58 am     Reply with quote

Yes, you have found a bug, but not a serious one, it is doing nothing only wasting a few bytes of memory and slows down your ISR a tiny bit.
Still worth to report to CCS at the above mentioned link.

tae wrote:
... they should reset an appropriate bit in IOCAF.
This has confused many other programmers on this forum but is correct behaviour. For most interrupts the CCS compiler clears the interrupt flag for you, which is nice. But the compiler can not clear the Interrupt-On-Change flag because it depends on your software. Sometimes, you as a programmer can have good reasons for not clearing the interrupt flag; for example when 3 pins have all changed but in your software you can only handle one change at a time. Perhaps you should write better software that can handle all changes at the same time, but that is up to you and not enforced by the CCS compiler.

For the correct procedure on clearing the IOC flags see the chapter 13.4 in the PIC12F1822 data sheet.
Ttelmah



Joined: 11 Mar 2010
Posts: 19537

View user's profile Send private message

PostPosted: Tue Dec 18, 2012 10:03 am     Reply with quote

Yes. Compile with the interrupt set to 'NOCLEAR', then the compiler will no longer generate the faulty code, and do the clear yourself the correct way (XOR the bits you have used, then AND this with the register).

A bug, should be reported, but easily programmed round.

Best Wishes
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Dec 18, 2012 7:29 pm     Reply with quote

In general, CCS does not clear the condition that caused the interrupt.
You have to do it manually, in code in the isr. For example, you have
to call getc() in #int_rda, and you have to read PortB, or a pin on PortB
in #int_rb, etc.

This post shows how to clear the IOCAF flag in a 12F1822:
http://www.ccsinfo.com/forum/viewtopic.php?t=46785&start=2
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