Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[SOLVED] toggle multiple pins in C

Status
Not open for further replies.

sri5496

Junior Member level 3
Junior Member level 3
Joined
Sep 28, 2012
Messages
29
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Location
UK
Visit site
Activity points
1,469
hi .


am bit new to programming am using dspic33f..need to toggle multiple pins in C progrm.. would appreciate if any one can help...
 

You must evaluate '0'´s and '1'´s separatelly.
Try this :
Code:
\\ iWord <= input operator pattern in which pins to be toggled bits are designed by '1'
\\ PORTx <= global variable representing I/O uC port

int iTemp = PORTx ;

PORTx &= ~ ( iWord & iTemp ) ;
PORTx |=  ( ~iWord & iTemp ) ;
 

Use a mask and the bitwise exclusive OR (XOR) operator, ^

PORTA ^= 0b00000011; //toggle bit0, bit1
PORTB ^= 0b00001100; //toggle bit2, bit3
 

Individual PIN Toggling

RB0 = ~RB0 // PORTB bit0
RC2 = ~RC2 // PORTC bit2


whats the different b/w LATB & PORTB ( LATCH & PORT )
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top