Gast
#1664145
Hallo, habe folgenden Code aus dem microchip PICKit3 LessonGuide und
verstehe eins nicht und bei einer anderen Stelle bräuchte ich nur ne
kurze Erläuterung.
Danke für die Hilfe.
PS: Switch_Pin ist RB0 und DetectsInARow ist einfach 5.
void main (void)
{
while (Switch_Count < DetectsInARow);
unsigned char Switch_Count = 0;
LED_Display = 1;// initialize
TRISD = 0b00000000;// PORTD bits 7:0 are all outputs (0)
INTCON2bits.RBPU = 0;// enable PORTB internal pullups
WPUBbits.WPUB0 = 1;// enable pull up on RB0
???Was machen diese beiden Befehle? Bzw. was Sie machen ist klar,
???aber was würde passieren, wenn ich das nicht eintippen würde?
ANSELH = 0x00;// AN8-12 are digital inputs (AN12 on RB0)
TRISBbits.TRISB0 = 1;// PORTB bit 0 (connected to switch) is
input (1)
while (1)
{
LATD = LED_Display;// output LED_Display value to PORTD LEDs
LED_Display <<= 1;// rotate display by 1
if (LED_Display == 0)
LED_Display = 1;
// rotated bit out, so set bit 0
while (Switch_Pin != 1);// wait for switch to be released
Switch_Count = 5;
????Warum Switch_Count = 5??????????????
do
{ // monitor switch input for 5 lows in a row to debounce if
(Switch_Pin == 0)
{ // pressed state detected
Switch_Count++;
}
else
{
Switch_Count = 0;
}
Delay10TCYx(25); // delay 250 cycles or 1ms. }
while (Switch_Count < DetectsInARow);