Pin Toggeling MCF5485

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Pin Toggeling MCF5485

1,162 Views
marek
Contributor I
Hi Commuity,

i am new to the Coldfire and try to toggel a pin as fast as possible.
The pin toggeling wasn't faster then ~1 Mhz.
I use the Cobra5485 board(from sentec) and thought that the toggling speed should be much faster.

here the source i used to toggel the pins.
Is there no way to toggel the pins faster?
I use the gcc crosscompiler.




#define IPSBAR 0x10000000

#define PAR_PCS3 (IPSBAR + 0xA4C)
#define PAR_PCS2 (IPSBAR + 0xA4D)
#define PAR_PCS1 (IPSBAR + 0xA4E)
#define PDDR_PSC3PSC2 (IPSBAR + 0xA1C)
#define PDDR_PSC1PSC0 (IPSBAR + 0xA1D)
#define PODR_PSC3PSC2 (IPSBAR + 0xA0C)
#define PODR_PSC1PSC0 (IPSBAR + 0xA0D)
int main(void );

void __main(void)
{
main();
}

int main(void)
{
int iCount;
unsigned char ucPortMask;


// set Ports to digital I/O:
(*(unsigned char *)(PAR_PCS3)) = 0x00;
(*(unsigned char *)(PAR_PCS2)) = 0x00;
(*(unsigned char *)(PAR_PCS1)) = 0x00;

// set Ports as outputs:
(*(unsigned char *)(PDDR_PSC3PSC2)) = 0x3F;
(*(unsigned char *)(PDDR_PSC1PSC0)) = 0xC0;


// switch the leds off:
*(unsigned char *)(PODR_PSC3PSC2) = 0x3F;
*(unsigned char *)(PODR_PSC1PSC0) = 0xC0;

ucPortMask = 0x01;
iCount=0;
*(unsigned char *)(PODR_PSC3PSC2) = 0x3F;
while(1)
{



if(iCount==1)
{
*(unsigned char *)(PODR_PSC1PSC0) = (unsigned char)0x01;
iCount=0;
}
else
{*
(unsigned char *)(PODR_PSC1PSC0) = (unsigned char)0xC0;
iCount=1;
}

}

return(0);
}



kind regards

marek
Labels (1)
0 Kudos
1 Reply

331 Views
Ciumbia
Contributor I
Well, in order to toggle a pin, it is very convenient to use the XOR function, like:
 
while (1)
   PORTB ^= 0x01;  //toggles the bit 0 of portb
 
this should be the fastest in C.
 
Regards,
 
Paolo.
0 Kudos