Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // rebound_calc.c
- // Calcule le temps de rebondissement d’un
- // bouton poussoir branche en pull-up sur
- // un bit de port du DS89C450.
- // Hacker: Samuel Duclos
- // Creative Commons licensed
- #include "MonDallas.h"
- #include <stdio.h>
- // Changez a volonte...
- #define BUTTON P1_3
- void main(void) {
- UI bounce = 0xDC00;
- SCON0 = 0x50;
- TMOD |= 0x21; // Timer 0 mode 16 bits.
- TH0 = 0xDC; // 10ms
- TH1 = 0xFF;
- PCON = 0x80;
- TR1 = 1;
- TI_0 = 1;
- printf("Branchez BUTTON et pesez dessus…\n");
- while (BUTTON);
- while (!BUTTON);
- TR0 = 1;
- while (!TF0) { if (BUTTON) { bounce = (TH0 << 8) + TL0; } }
- printf("Temps de rebond d’environ %f millisecondes.\n", (65536 - bounce) / 921.6);
- while (1);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement