Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <C8051F340.h>
- void configTimer (void);
- void configInterruption (void);
- void reloadTimer (void);
- void switch_0 (void) __interrupt 0;
- void switch_1(void) __interrupt 2;
- void RSI_Timer0 (void) __interrupt 1;
- char overflowCounter = 0;
- char threshold = 128;
- int main (void) {
- configTimer();
- configInterruption();
- TR0 = 1;
- while (1) {
- if (overflowCounter<=threshold) {
- P2_2=1;
- } else {
- P2_2=0;
- }
- }
- }
- void RSI_Timer0 (void) __interrupt 1 {
- overflowCounter++;
- }
- void switch_0 (void) __interrupt 0 {
- threshold++;
- }
- void switch_1 (void) __interrupt 2 {
- threshold--;
- }
- void configTimer (void) {
- P2MDOUT = 0x0C;
- P0SKIP = 0xFF;
- P1SKIP = 0xFF;
- XBR1 = 0X70;
- OSCICN = 0x83;
- PCA0MD &= 0xBF;
- PCA0MD = 0x00;
- reloadTimer ();
- TMOD=0x01;
- }
- void configInterruption (void) {
- IE=0x87;
- IT01CF=0xC1;
- }
- void reloadTimer (void) {
- TH0=0xFC;
- TL0=0xFC;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement