When will CCR.V be set? Could you give an example?

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

When will CCR.V be set? Could you give an example?

147 Views
fqh
Contributor I

The MCU is MC9S12ZVCA96, and the IDE is codewarrior 10.7.

We need to check the overflow bit CCR.V after an addition operation.

There is no intrinsic function for CCR.V checking. So we can't let the compiler to generate BVC/BVS instruction except assembly language.

 

0 Kudos
Reply
1 Reply

110 Views
lama
NXP TechSupport
NXP TechSupport

Hi,

yes you can do any of ASM branch instructions or you can use following code and then work with C and defined variable. The OV test is not a standard function because it would require  application SW reaction. It would enter additional code which is usually not necessary. This must be handled by app. engineer which also leads him to think about used variables ranges.

//================= GLOBAL VARIABLES ===================================
unsigned char CCRbackup;  // temp variable to store CCRL, byte because CCRL is only used
//================= MACROS ==========================================

// save CCR to variable CCRbackup ... reg. D0 is used as an information carrier
#define getCCR() { asm PSH D0;   asm TFR CCL,D0;   asm ST D0, CCRbackup;   asm PUL D0; }

//==================================================================
// Main
//==================================================================
void main(void)
{
  //------------------------
  // example of reading CCR start, the CCR is tored into the global variable CCRbackup
  //------------------------
  getCCR();                              // the CCRL is stored in the CCRbackup variable
  //------------------------

 

Best regards,

Ladislav