IF statement Oddity (seems to me)

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

IF statement Oddity (seems to me)

1,339 Views
UtopiaTim
Contributor III

Hi Folks,

 

I have a completed a couple of projects written in C, and I've come across something that

seems to be a bit strange to me.

 

I'm sure that it's probably something simple, but here goes.

 

This is what I would like to do:

 

unsigned char data;

.

.

.

  if (data == 0x0b){
     inhibit = 0;   
  }

 

Pretty simple.  If a location called 'data' is = to $0b, then make inhibit 0.

 

It doesn't <always> work.  I usually end up doing !=, then changing the

structure of the way the routine works.

 

I've seen this on the JM60 & QG8 versions of CW.  I'm using 6.1 currently.

 

Thanks,


Tim

Labels (1)
0 Kudos
Reply
2 Replies

517 Views
bigmac
Specialist III

Hello Tim,

 

You do not say whether data is a local variable or a global variable.  If a global variable, can the variable be written via an ISR?  If so, the variable definition should include the volatile modifier.

 

Regards,

Mac

 

0 Kudos
Reply

517 Views
UtopiaTim
Contributor III

Hi Mac,

 

Thanks for the reply.

 

Right now, I'm writing the code as a single module, and there are

no interrupts.  (it's a very simple project).

 

 

Tim

 

 

0 Kudos
Reply