// *************************************************************************** // File Name : 7ss.c // Version : 1.2 // Description : 7 segment display with 74HC595 // // Author : Mikael Frisk(Mixmar on LMR) // Target : Pic 16f690 on breadboard // Compiler : HITECH PICC-Lite Version 9.83 // IDE : Microchip MPLAB X IDE // Programmer : PICKit2 // Last Updated : 10 Nov 2012 // *************************************************************************** #include /* PIC Configuration Bit: ** INTIO/FOSC_INTRCIO - Using Internal RC No Clock ** WDTDIS/WDTE_OFF - Wacthdog Timer Disable ** PWRTEN/PWRTE_ON - Power Up Timer Enable ** MCLREN/MCLRE_ON - Master Clear Enable ** UNPROTECT/CP_OFF - Code Un-Protect ** UNPROTECT/CPD_OFF - Data EEPROM Read Un-Protect ** BORDIS/BOREN_OFF - Brown Out Detect Disable ** IESODIS/IESO_OFF - Internal External Switch Over Mode Disable ** FCMDIS/FCMEN_OFF - Monitor Clock Fail Safe Disable */ __CONFIG( FOSC_INTRCIO & WDTE_OFF & PWRTE_ON & MCLRE_ON & CP_OFF & CPD_OFF & BOREN_OFF & IESO_OFF & FCMEN_OFF ); #define FOSC 8000000L // Using Internal Clock of 8 Mhz #define DS RC2 //data on pin C2 #define ST_CP RC1 //storage register clock input on pin C1 #define SH_CP RC0 //shift register clock input on pin C0 #define testbit(data,bitno) ((data>>bitno)&0x01) unsigned int i,x,ty; unsigned char Digit[10] = {0x03,0x9F,0x25,0x0D,0x99,0x49,0x41,0x1F,0x01,0x09}; //Array containing all the "digits" /* **0x03 hex = 0 dec = 0000 0011 bin **0x9F hex = 1 dec = 1001 1111 bin **0x25 hex = 2 dec = 0010 0101 bin **0x0D hex = 3 dec = 0000 1101 bin **0x99 hex = 4 dec = 1001 1001 bin **0x49 hex = 5 dec = 0100 1001 bin **0x41 hex = 6 dec = 0100 0001 bin **0x1F hex = 7 dec = 0001 1111 bin **0x01 hex = 8 dec = 0000 0001 bin **0x09 hex = 9 dec = 0000 1001 bin */ void init(void) { OSCCON=0x70; // Select 8 Mhz internal clock TRISC = 0x00; // Set all as Output ANSEL = 0; ANSELH = 0; } void dirty_delay(int count){ for(int s=0;s