is the same effect in updation of Timer 0 resister

saj's picture
saj

Offline

Joined: Sep 28, 2018

Replies: 12
is the same effect in updation of Timer 0 resister
November 26, 2018 - 6:39pm

Hi there,

My code is as follws:

for The LED will flash when MSB of TMR0 is update to '1'. 

if (TMR0 & 1<<7)
LATAbits.LATA0 = 1;
else
LATAbits.LATA0= 0;

 

And i have seen this can be  written as below and will have same effect.

LATAbits.LATA0 = (TMR0 & 1<<7) != 0; // FLASH = TMR0<7>

Because, when  when MSB of TMR0 is '1', the '1'&'1' is '1' and  '1!' is '0', so statement is TRUE

 

Can I write above as below, in place of above and will have it same effect as above has,

//LATAbits.LATA0 = (TMR0 & 1<<7) = 1; // FLASH = TMR0<7>

because when MSB of TMR0 is '1', the '1'&'1' is '1' and statement is TRUE.

 

Please clear my doubt

tnx for your reply in advance..

Jayant's picture

Offline

Joined: May 19, 2015

Replies: 185
MCU and programming IDE name
November 26, 2018 - 6:52pm

Hi are you usig the LPC? Which MCU are you using and what program IDE is this? 

saj's picture
saj

Offline

Joined: Sep 28, 2018

Replies: 12
sorry to define that..
November 26, 2018 - 8:58pm

sorry to define that..

its PIC12f1501 mcu and XC8.

tnx

saj's picture
saj

Offline

Joined: Sep 28, 2018

Replies: 12
is the same effect in updation of Timer 0 resister
December 1, 2018 - 5:10pm

hi,

with the above details and compiler xc8.:

 

LATAbits.LATA0 = (TMR0 & 1<<7) != 0; // FLASH = TMR0<7>

 

It is same fudamentally as well as logically in its operation too??

and Can I write in place of above and will have it same effect as above has,

LATAbits.LATA0 = (TMR0 & 1<<7) = 1; // FLASH = TMR0<7>

pl clear my doubt??