aliyesami
Full Member level 6
- Joined
- Jan 7, 2010
- Messages
- 369
- Helped
- 0
- Reputation
- 0
- Reaction score
- 0
- Trophy points
- 1,296
- Location
- USA
- Activity points
- 4,190
this is a working code that is combining the databits on two different ports and I am not understanding how it is working.
if we AND PORTB to ~0x3F which is 0xC0 , it will make bits DB0-DB5 all zeros so how is the PORTB and PORTC
assignments working ?
if we AND PORTB to ~0x3F which is 0xC0 , it will make bits DB0-DB5 all zeros so how is the PORTB and PORTC
assignments working ?
Code:
/*-------------------------------------------------
DATA mapping:
DB0 DB1 DB2 DB3 DB4 DB5 DB6 DB7
PB0 PB1 PB2 PB3 PB4 PB5 PC6 PC7
CONTROL mapping:
RES RD WR RS
PC2 PC3 PB4 PB5
---------------------------------------------------*/
#define DMSK 0x3F
void write_8(unsigned char c)
{
PORTB = (PORTB & ~DMSK)|(c & DMSK);
PORTC = (PORTC & DMSK)|(c & ~DMSK);
.
.
}
void TFT_setup(void)
{
DDRB |= DMSK;
DDRC |= ~DMSK;
DDRC |= 0x3C;
.
.
}