MikroElektronika PIC Microcontrollers PIC16 Ficha de datos Pagina 173

  • Descarga
  • Añadir a mis manuales
  • Imprimir
  • Pagina
    / 194
  • Tabla de contenidos
  • SOLUCIÓN DE PROBLEMAS
  • MARCADORES
  • Valorado. / 5. Basado en revisión del cliente
Vista de pagina 172
Programming PIC Microcontrollers in BASIC - mikroElektronika
PORTA = 1 ' Turn on 1st 7seg, turn off 2nd
v = 1
else
PORTB = por1 ' Send mask of ones to PORTB
PORTA = 2 ' Turn on 2nd 7seg, turn off 1st
v = 0
end if
TMR0 = 0 ' Clear TMRO
INTCON = $20 ' Clear TMR0IF and set TMR0IE
end sub
main:
OPTION_REG = $80 ' Pull-up resistors
TRISA = 0 ' PORTA is output
TRISB = 0 ' PORTB is output
PORTB = 0 ' Clear PORTB (make sure LEDs are off)
PORTA = 0 ' Clear PORTA (make sure both displays are off)
TMR0 = 0 ' Clear TMRO
por1 = $7F ' Mask for '8' (check the table above)
por2 = $4F ' Mask for '3' (check the table above)
INTCON = $A0 ' Enable T0IE
while true ' Endless loop, wait for interrupt
nop
wend
end.
The multiplexing problem is solved for now, but your program probably doesn’t have a sole purpose of printing constant
values on 7seg display. It is usually just a subroutine for displaying certain information. However, this approach to
printing data on display has proven sto be very convenient for more complicated programs. You can also move part of
the program for refreshing the digits (handling the masks) to the interrupt routine.
The following example increases variable i from 0 to 99 and prints it on displays. After reaching 99, counter begins anew.
program seven_seg_counting
dim i as byte
dim j as byte
dim v as byte
dim por1 as byte
http://www.mikroelektronika.co.yu/english/product/books/picbasicbook/07.htm (7 sur 16)05/11/2004 02:27:46
Vista de pagina 172
1 2 ... 168 169 170 171 172 173 174 175 176 177 178 ... 193 194

Comentarios a estos manuales

Sin comentarios