is the same effect in updation of Timer 0 resister

Submitted by saj on Mon, 11/26/2018 - 18:39

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..

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

  Joined May 19, 2015      213
Tuesday at 03:45 PM

sorry to define that..

its PIC12f1501 mcu and XC8.

tnx

  Joined September 28, 2018      26
Friday at 01:20 AM

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??

  Joined September 28, 2018      26
Friday at 01:20 AM