/* FILE / DATE: dcf_sim_.c / 2010-05-03 DESCRIPTION: DCF Simulator MICRO-PROCESSOR: PIC16F886 COMPILER: B Knudsen Cc5x C-compiler - not ANSI-C EXTERNAL HW: LCD Display 4 pushbuttons with LED Rotating encoder 2 LEDs DESIGNER: Hans Sundgren CREDIT: William Sandqvist for rotary encoder reading RAM usage: 172 bytes (12 local), 196 bytes free CODE WORDS: 4450 code words (54 %) CHIP CONNECTIONS ******************************************** _________ ________ | \/ | | 16F886 | -|RE3 1 28 RB7|- Output.PULSE--<-|RA0 2 27 RB6|- LCD.backlight-<-|RA1 3 26 RB5|-<-Btn.START LED.SET------<-|RA2 4 25 RB4|-<-Btn.TRANSMIT LED.VIEW-----<-|RA3 5 24 RB3|-<-Btn.VIEW LED.TRANSMIT-<-|RA4 6 23 RB2|-<-Btn.SET LED.START----<-|RA5 7 22 RB1|-<-Encoder.A GND---|Vss 8 21 RB0|-<-Encoder.B LED.one-<-|RA7 9 20 Vdd|---+5V LED.null-<-|RA6 10 19 Vss|---GND XTAL 32,768 kHz---|OSO 11 18 RC7|->-LCD.D7 XTAL 32,768 kHz---|OSI 12 17 RC6|->-LCD.D6 LCD.RS-<-|RC2 13 16 RC5|->-LCD.D5 LCD.EN-<-|RC3 14 15 RC4|->-LCD.D4 |___________________| DISPLAY VIEWS, 1 -> 2 -> 3 -> 4 -> 1 -> ... _____________________________________________ | View | Shows | LCD backlight | |------|----------------------|---------------| | 1 | Time and bit display | No | | 2 | Time and bit display | Yes | | 3 | Bit overview | Yes | | 4 | Bit description | Yes | |______|______________________|_______________| PUSH-BUTTONS ____________________________________________________________ | Button | Color | Pin | Lamp, pin: lit | |------------|--------|-----|--------------------------------| | Start/Stop | Green | RB5 | RA5 | On during clock running | | Transmit | Red | RB4 | RA4 | Blink on output signal | | View | Blue | RB3 | RA3 | Blink when pressed | | Set | Yellow | RB2 | RA2 | On during set clock | |____________|________|_____|________________________________| LED INDICATORS ____________________________________________________________ | LED | Color | Pin | Lit during... | |------------|--------|-----|--------------------------------| | 0 | Yellow | RA7 | Output = 0 | | | | | Decrement during clock setting | | | | | | | 1 | Green | RA6 | Output = 1 | | | | | Increment during clock setting | |____________|________|_____|________________________________| ROTATING DIALS ____________________________________________________________ | Type | Function | Pin | |----------------|-------------------------------------------| | Rotary encoder | Increase/decrease clock setting | RB0/RB1 | |________________|_________________________________|_________| PROGRAM OVERVIEW ******************************************* Interrupt: 1 Hz ---------------------------------------- | If start_mode = 1 | | Update clock (step up one second) | | Output pulse-value | | Update display | | Check buttons | | If VIEW-button | | Step up display mode 0->1->2->3->0 | | If SET-button | | Setting > 0 | | Stop interrupt, jump out to setting sequence | -------------------------------------------------------- Interrupt: Rotary encoder, during "set clock" ---------- | Read encoder | | If increase | | up = 1 and blink LED0 | | If decrease | | down = 1 and blink LED1 | -------------------------------------------------------- Main --------------------------------------------------- | Initialization | | Read stored time from EEPROM | | Interrupt is active 1 Hz, but the clock is stopped | | Loop | | Check START-button | | If START-button | | Toggle start_mode | -------------------------------------------------------- Set clock sequence ------------------------------------ | Disable 1 Hz interrupt | | Enable rotary encoder interrupt | | Step through set sequence, read rotary encoder | | Update and display time values | | Store set time in EEPROM | | Enable 1 Hz interrupt | -------------------------------------------------------- */