View previous topic :: View next topic |
Author |
Message |
Guest
|
BF flag vs. interrupt flag |
Posted: Fri Sep 17, 2004 1:43 pm |
|
|
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
|
|
Posted: Fri Sep 17, 2004 2:48 pm |
|
|
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
|
BF flag vs interrupt flags for SPI |
Posted: Sat Sep 18, 2004 7:25 pm |
|
|
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
|
|
Posted: Mon Sep 20, 2004 2:19 pm |
|
|
So it doesn't seem to be an improvement? |
|
|
Trampas
Joined: 04 Sep 2004 Posts: 89 Location: NC
|
|
Posted: Mon Sep 20, 2004 3:17 pm |
|
|
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
|
|
Posted: Mon Sep 20, 2004 3:41 pm |
|
|
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
|
|
Posted: Mon Sep 20, 2004 5:17 pm |
|
|
If you use a version control software, it is nice to link the tools to the source. |
|
|
|