Interfacciamento
• emissione su stampante di un dato che
rappresenta una tensione acquisita da un
convertitore analogico digitale
• decodifica e visualizzazione del segnale
orario dell’Istituto Galileo Ferraris diffuso
dalla RAI
Modalità di realizzazione
• Acquisizione d.d.p.
• tramite Personal Computer
• tramite microcontrollore 80552
• Decodifica oraria
• tramite Personal Computer
• tramite microcontrollore 80552
SCHEMA A BLOCCHI
Acquisizione d.d.p.
tramite personal computer
d.d.p.
scheda ADC
PC
programma
stampante
SCHEMA A BLOCCHI
Acquisizione d.d.p.
tramite microcontrollore 80552
d.d.p.
microcontrollore 80552
contiene un ADC a 10 bit
programma
stampante
Blocchi funzionali
voltmetro
Acquisizione
dati
Start
Conversione
formato
Lettura
Reset
Stampa
tensioni
Invio sincrono
Vuota buffer
Temporizzazioni stampante
Segmento di acquisizione e
conversione formato
outportb(adc,0x1);
delay(1);
dato = inportb(adc);
num = dato * 0.01953;
sprintf(dato_stampa,"%f",num);
for (i=0; i<5; i++){
outportb(port, dato_stampa[i]);
}
...
SCHEMA A BLOCCHI
Decodifica segnale orario tramite personal computer
segnale B.F.
RAI
PLL
lpt1
PC
display 7 seg.
programma
video
SCHEMA A BLOCCHI
Decodifica segnale orario tramite microcontrollore
80552
segnale B.F.
RAI
PLL
80552
programma
display 7 seg.
Segnale orario codificato
Blocchi funzionali
orario
decodifica segnale
attendi
sincronismo
leggi i bit
del segnale
emetti display
attiva
digit
attiva
segmento
stampa video
solo PC
Segmento stampa_display
void stampa_display(unsigned long dato_letto)
{
unsigned char temp,temp1;
struct orario{
unsigned Parita2 : 1;
unsigned gioS : 3;
unsigned gioU : 4;
unsigned gioD : 2;
unsigned mesU : 4;
unsigned mesD : 1;
unsigned Parita1 : 1;
unsigned Legale : 1;
unsigned minU : 4;
unsigned minD : 3;
unsigned oraU : 4;
unsigned oraD : 2;
};
union {
struct orario y;
unsigned long letto;
} x ;
x.letto = dato_letto;
#define rai(tv) 0x0B ^ x.y.tv
Struttura microcontrollore 80552
Dettaglio memoria
SFRegisters
C:\disco_d\SCUOLA\sheet\80c552overwiev.pdf
HEADER per 80552
/*
- IO525.H -
Special header for the 80C552 processor.
Version 4.00 [IANR]
*/
#pragma language=extended
/*===============================*/
/* Predefined SFR Byte Addresses */
/*===============================*/
sfr
sfr
sfr
sfr
sfr
sfr
P0
P1
P2
P3
P4
P5
= 0x80;
= 0x90;
= 0xA0;
= 0xB0;
= 0xC0;
= 0xC4;
sfr
sfr
sfr
sfr
PSW
= 0xD0;
ACC
= 0xE0;
B
= 0xF0;
SP
= 0x81;
HEADER 80552
/* ######################### 8X51 and 8xC51 ########################### */
#define P0 (*(unsigned char *)(0x80))
#define SP (*(unsigned char *)(0x81))
#define PCON (*(unsigned char *)(0x87))
#define TCON (*(unsigned char *)(0x88))
#define TMOD (*(unsigned char *)(0x89))
#define TL0 (*(unsigned char *)(0x8a))
#define TL1 (*(unsigned char *)(0x8b))
#define TH0 (*(unsigned char *)(0x8c))
#define TH1 (*(unsigned char *)(0x8d))
#define P1 (*(unsigned char *)(0x90))
#define SCON (*(unsigned char *)(0x98))
#define SBUF (*(unsigned char *)(0x99))
#define P2 (*(unsigned char *)(0xA0))
#define IE (*(unsigned char *)(0xA8))
#define P3 (*(unsigned char *)(0xB0))
#define IP (*(unsigned char *)(0xB8))
#define PSW (*(unsigned char *)(0xD0))
#define ACC (*(unsigned char *)(0xE0))
#define B (*(unsigned char *)(0xF0))
Compilatore e Linker
IAR
• compilatore
• ICC8051 -ms -L -q -P <path> nomefile.C
• linker
• XLINK - f <path> nomefile.XCL
Il File nome.XCL
-!
-LNK8051.XCLXLINK 4.2x command file to be used with the 8051 C-compiler V4.xx
using the -mt, -ms, -mc, -mm or -ml memory model
Usage: xlink your_file(s) -f lnk8051l
First: define CPU -!
-c8051
-! Select register bank [0,8,10 or 18]-!
-D_R=0
-! Setup "bit" segments (always zero if there is no need to reserve
bit variable space for some other purpose) -!
-Z(BIT)C_ARGB,BITVARS=0
-! Setup "data" segments. Start address may not be less
than _R+8 (start of register bank + 8). Space must also
be left for interrupt functions with the "using" attribute.
That is, if _R is 0 and there is an interrupt function with
using [1], the start address should be set to 10 (hex) -!
-Z(DATA)C_ARGD,D_UDATA,D_IDATA=8
ecc.
File in formato INTEL
:10028D001203317810E4F608F6C37811E6940618D7
:10029D00E69400506A75C5087F017E0012035D78F3
:1002AD0016A6C675C5007816E6FFE4FEFDFC120223
:1002BD00517B617AFD799F783C1200B57812A604C6
:1002CD0008A60508A60608A607780AE4F608F6C3E8
:1002DD00780BE6940518E69400501075C041120392
:1002ED0011780B06E61870010680E412034C7FE8C6
:1002FD007E0312035D781106E618700106808A7F71
:10030D00007E00227F017E0012035D7590FE7F014D
:10031D007E0012035D7590FF7F017E0012035D7FED
:10032D00007E00227590FF7F017E0012035D75C077
:10033D001B12031175C0401203117F007E00227540
:10034D00C00A12031175C00D1203117F007E002229
:10035D007808A60608A607780CE4F608F6C3780D0B
:10036D00E679099718E619975026780EE4F608F6FF
:10037D00C3780FE694DC18E69405500A780F06E66C
:10038D001870010680EA780D06E61870010680CD1A
:01039D00223D
:03000000020003F8
:1000030075811678167600D8FC900000AE83AF8217
...
parte di file pronto per essere inviato ad un
programmatore di EPROM
Scarica

Il linguaggio “C” nella programmazione di