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

BF flag vs. interrupt flag

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








BF flag vs. interrupt flag
PostPosted: Fri Sep 17, 2004 1:43 pm     Reply with quote

The latest CCS update states:

SPI_WRITE now uses the BF flag to signal complete, not the interrupt flag

What is the advantage? Will the code run faster this way?
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Fri Sep 17, 2004 2:48 pm     Reply with quote

For the PCM compiler, they've been testing the BF flag for a long time.
I tested these versions:

2.734
3.188
3.207
3.210

They all test register 0x94, bit 0. This is the BF flag for the 16F877.

So maybe this announcement is for PCH ? I don't know.
I don't have the latest versions of PCH.
regan



Joined: 10 Sep 2003
Posts: 5
Location: Wellington, New Zealand

View user's profile Send private message Send e-mail

BF flag vs interrupt flags for SPI
PostPosted: Sat Sep 18, 2004 7:25 pm     Reply with quote

I wrote my own SPI transfer routines for use with PCH and the PIC18F range. I couldn't get stable behaviour from the BF flag, so I used the interrupt flag instead. Errata documents released by Microchip indicate a problem with the BF flag, but the criteria they mentioned was never the case with my code, yet I still got errors. So, I found that the interrupt flag was more reliable. Microchip may now have clarified what the cause of the problem was.

Code:

/////////////////////////////////////////////////////////////////////////
int     spi_transfer(int value)
{
    bit_clear(_PIR1,3);
    _SSPBUF=value;
    while(!bit_test(_PIR1,3));
    return(_SSPBUF);
}
/////////////////////////////////////////////////////////////////////////


regan
Guest








PostPosted: Mon Sep 20, 2004 2:19 pm     Reply with quote

Shocked

So it doesn't seem to be an improvement?
Trampas



Joined: 04 Sep 2004
Posts: 89
Location: NC

View user's profile Send private message MSN Messenger

PostPosted: Mon Sep 20, 2004 3:17 pm     Reply with quote

I think some of it was a bug... I know that one version of CCS would used the interrupt and the SPI would not work. Then the next version would use the BF and it would work. Then they kept switching back and forth causing head aches for the developers.

Generally Mark and others have made very conviencing points that if you are using the compiler's intrensic functions you will at some point have your code broken by updating the compiler...

Trampas
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Sep 20, 2004 3:41 pm     Reply with quote

What I do is to document the compiler version that was used to create
a particular program. This information goes at the top of the main
source file. Then if I ever want to modify that program again, I install
that version of the compiler.
Mark



Joined: 07 Sep 2003
Posts: 2838
Location: Atlanta, GA

View user's profile Send private message Send e-mail

PostPosted: Mon Sep 20, 2004 5:17 pm     Reply with quote

If you use a version control software, it is nice to link the tools to the source.
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