summaryrefslogtreecommitdiffstats
path: root/test/sdcc/blinker_sdcc250.c
blob: ffe2dc86c3ff6214931484f9d932c9ffdbe4b879 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#define __16F873
#include "sdcc250_pic16f873.h"

typedef unsigned int word;
word at 0x2007 CONFIG = _CP_OFF & _WDT_OFF & _BODEN_ON & \
         _PWRTE_ON & _HS_OSC & _WRT_ENABLE_ON & \
         _LVP_OFF & _DEBUG_OFF & _CPD_OFF;

unsigned char count, x = 2;
unsigned char ms_delay;

void Intr() interrupt 0 {
  ms_delay++;
  PIR1 = 0;
  PEIE = 1;
}

void main() {
  NOT_RBPU = 0;
  T2CON = 0x7f;
  GIE = 1;
  PEIE = 1;
  //INTCON=0xc0;
  PIR1 = 0;
  PIE1 = 2;
  PR2 = 200;

  TRISB = 0;
  ms_delay = 0;
  while(1) {
    count = ms_delay;
    x = PIE1;
    PORTB = (count & 0xf0) | (x & 0xf);
  }
}