venerdì 25 marzo 2016

Display 7 Led su Pic Dev Board

Lo schema elettrico per attivare il display a 7 Led sulla Pic Dev Board e' mostrato qui sotto




Per comandare quale posizione dei display si deve agire sulla porta A. Per esempio impostando la maschera dei bit della porta A a 0xFD si attiva il secondo posto da sinistra (maschera 11111101)  mentre con 0xDF si attiva il 6° posto da sinistra (maschera 11011111)
Impostando la porta D si decide quale carattere mostrare

Per attivare il display a 7 Led si deve spostare il jumper bianco del connettore 5x2 sulla prima posizione (VCC-SW)

Questo e' il programma
-----------------------------------
#include <xc.h>


// CONFIG
#pragma config FOSC = XT        // Oscillator Selection bits (XT oscillator)
#pragma config WDTE = OFF       // Watchdog Timer Enable bit (WDT disabled)
#pragma config PWRTE = OFF      // Power-up Timer Enable bit (PWRT disabled)
#pragma config BOREN = ON       // Brown-out Reset Enable bit (BOR enabled)
#pragma config LVP = OFF        // Low-Voltage (Single-Supply) In-Circuit Serial Programming Enable bit (RB3 is digital I/O, HV on MCLR must be used for programming)
#pragma config CPD = OFF        // Data EEPROM Memory Code Protection bit (Data EEPROM code protection off)
#pragma config WRT = OFF        // Flash Program Memory Write Enable bits (Write protection off; all program memory may be written to by EECON control)
#pragma config CP = OFF         // Flash Program Memory Code Protection bit (Code protection off)

const unsigned char LED[]=
{                         
0xc0,0xf9,0xa4,0xb0,//0~3
0x99,0x92,0x82,0xf8,//4~7
0x80,0x90,0x88,0x83,//8~b
0xc6,0xa1,0x86,0x8e //c~f
};

void delay(unsigned int count);

void main(void)            
{
  unsigned int i;
  
    TRISA&=0XFD;        
TRISD=0B00000000; 
    PORTD=0xFF;       
    PORTA=0XFD;       

    while(1)        
    {
    for(i=0;i<16;i++)
      {
       PORTD=LED[i];
       delay(30);
      }
    }
}

void delay(unsigned int count)
{
unsigned int a,i;
for(i=0;i<count;i++)
{
for(a=0;a<5000;a++)
 asm("NOP");  
}
}

-----------------------------------









Nessun commento:

Posta un commento

Physics informed neural network Fukuzono

Visto che puro ML non funziona per le serie tempo di cui mi sto occupando ed le regressioni basate su formule analitiche mostrano dei limiti...