Yahoo Groups archive

AVR-Chat

Index last updated: 2026-04-28 22:41 UTC

Thread

read-modify port

read-modify port

2003-12-27 by mirza_4

Hi, all...

i have implemented dtmf generator on 2313.
now i need to use other Port B pins as general IO.
i use the following code to read PORTB0 state and then write it back:

void modifyPortB (void)
{
	unsigned char temp, temp1;

	temp = PORTB;   
	temp1 = temp; 
	temp1 &= 0xfe;       
	temp = ~temp;
	temp &= 0x01; 
	PORTB = (temp1 | temp);
}

but with oscilloscope i observe a "glitch" on PWM signal.
Any suggestions?

TIA
-mirza-

Re: [AVR-Chat] read-modify port

2003-12-27 by Jesper Hansen

> i have implemented dtmf generator on 2313.
> now i need to use other Port B pins as general IO.
> i use the following code to read PORTB0 state and then write it back:
> 
> void modifyPortB (void)
> {
> unsigned char temp, temp1;
> 
> temp = PORTB;   
> temp1 = temp; 
> temp1 &= 0xfe;       
> temp = ~temp;
> temp &= 0x01; 
> PORTB = (temp1 | temp);
> }
> 
> but with oscilloscope i observe a "glitch" on PWM signal.
> Any suggestions?

Try this :

PORTB ^= 1;

Which does the same as your code. (Which I don't understand the purpose of).


/Jesper
www.yampp.com

Move to quarantaine

This moves the raw source file on disk only. The archive index is not changed automatically, so you still need to run a manual refresh afterward.