/*
* File: PROPELLER CLOCK
* Author:
*
* Created on 08/06/16
*/
// PIC16F88 Configuration Bit Settings
// 'C' source line config statements
#include <xc.h>
// #pragma config statements should precede project file includes.
// Use project enums instead of #define for ON and OFF.
// CONFIG1
#pragma config FOSC = INTOSCIO // Oscillator Selection bits (INTRC oscillator; port I/O function on both RA6/OSC2/CLKO pin and RA7/OSC1/CLKI pin)
#pragma config WDTE = OFF // Watchdog Timer Enable bit (WDT disabled)
#pragma config PWRTE = OFF // Power-up Timer Enable bit (PWRT disabled)
#pragma config MCLRE = ON // RA5/MCLR/VPP Pin Function Select bit (RA5/MCLR/VPP pin function is MCLR)
#pragma config BOREN = OFF // Brown-out Reset Enable bit (BOR disabled)
#pragma config LVP = OFF // Low-Voltage Programming Enable bit (RB3 is digital I/O, HV on MCLR must be used for programming)
#pragma config CPD = OFF // Data EE Memory Code Protection bit (Code protection off)
#pragma config WRT = OFF // Flash Program Memory Write Enable bits (Write protection off)
#pragma config CCPMX = RB0 // CCP1 Pin Selection bit (CCP1 function on RB0)
#pragma config CP = OFF // Flash Program Memory Code Protection bit (Code protection off)
// CONFIG2
#pragma config FCMEN = OFF // Fail-Safe Clock Monitor Enable bit (Fail-Safe Clock Monitor disabled)
#pragma config IESO = OFF // Internal External Switchover bit (Internal External Switchover mode disabled)
#define GSCLK RB5
#define XLAT RB6
#define BLANK RB7
/* -------------------------------------------------------------------------------------
LIBREIRE
--------------------------------------------------------------------------------------*/
#include <xc.h>
#include <stdio.h>
#include <stdlib.h>
#include <pic.h>
/* -------------------------------------------------------------------------------------
COSTANTI
--------------------------------------------------------------------------------------*/
unsigned char a[]={0x80,0x0F,0xFF,0xFF,0xFF,0xFF,
0x80,0x00,0x00,0xBB,0x80,0x00,
0xFF,0xF0,0x00,0x00,0x0F,0xFF,
0x00,0x00,0x00,0x00,0x00,0x00};
unsigned char i=0;
unsigned char x=0;
/* -------------------------------------------------------------------------------------
VARIABILI
--------------------------------------------------------------------------------------*/
/* -------------------------------------------------------------------------------------
PROTOTIPI FUNZIONI
--------------------------------------------------------------------------------------*/
void InitGen();
/* -------------------------------------------------------------------------------------
Funzione: exec_irq [INTERRUPT]
DESCRIZIONE: Programma di gestione degli interrupt
--------------------------------------------------------------------------------------*/
static void interrupt irq_exec(void)
{
// if(TMR0IF)
// GSCLK=!GSCLK;
//
// TMR0IF=0;
}
/* -------------------------------------------------------------------------------------
Funzione: MAIN
-------------------------------------------------------------------------------------*/
void main()
{
InitGen();
while(1)
{
for(i=0;i>=24;i++)
{
SSPBUF=a[i];
while(!SSPIF);
SSPIF=0;
i++;
}
i=0;
XLAT=1;
BLANK=1;
BLANK=0;
}
}
/*------------------------------------------------------------------------------
NOME FUNZIONE: init_gen
DESCRIZIONE: inizializzazione generale del sistema, eseguita solo al RESET
------------------------------------------------------------------------------*/
void InitGen()
{
OSCCON&=0B10001111;
OSCCON|=0B01100000; // Attiva oscillatore interno a 4MHz
// Inizializzazione memorie varie
// Inizializzazione A/D Converter RA0
//CMCON=0x07; //Disabilita il Comparator Module
ANSEL=0;
// ADCON0=0B01000000; //Fosc/8, A/D enable OFF
// ADCON1=0B01000000; //Valore convertito giustificato a DX
//VDD and VSS (0-5V) come RANGE di tensione
// Inizializzazione registro I/O
PORTA=0B00000000;
TRISA=0B11111111; //0=output,1=input
PORTB=0B00000000;
TRISB=0B11001011; //0=output,1=input
// Inizializzazione TMR0
OPTION_REG=0x03; // Div 16
TMR0=193; // Preset durata TICK di sistema
// Inizializzazione TMR1
/*
TMR1H=0;
TMR1L=0;
T1CON=0x05; // 1/1 prescaler, clock 4MHz
*/
// Inizializzazione TMR2
/*
T2CON=0x07; // 1/16 prescaler, clock 4MHz
TMR2=84;
*/
// Inizializzazione Trasmissione Asincrona
/*
//TXSTA
TX9=0; //8 BIT
TXEN=1; //ABILITAZIONE TX
SYNC=0; //ASINCRONO
SENDB=0;
BRGH=1; //HIGH SPEED BAUD RATE
//RCSTA
SPEN=1; //RB2=RX RB5=TX
RX9=0; //RICEVE 8BIT
CREN=1; //RICEZIONE CONTINUA
//BAUD RATE
SPBRG=25; //9600B/s f=4MHz
*/
// Inizializzazione INTCON
//INTEDG=0;
//PIR1=0;
//PIR2=0;
//TMR0IF=0;
//TMR0IE=1;
INTCON=0;
SSPSTAT=0;
SSPCON=0B00100001;
TMR0IF=0;
TMR0IE=1;
GIE=0; // Abilitazione generale degli IRQ
}