728x90

728x90

Wednesday, May 20, 2020

Driving a single 8x8 dot matrix display using PIC16F887

Just like multiplexing a multi-digit seven-segment display, driving a dot matrix display does the same thing.
Here, I don't explain more about a dot matrix display due to the other article that I have posted "using ATMega32 to drive a single 8x8 dot matrix display".

In this example, I use PortD to display the matrix pattern, and PortC for controlling the common. The dot matrix display I used is common cathode type.

Driving a single 8x8 dot matrix display using PIC16F887
Schematic diagram.
PortD outputs the character data.
PortC control each common dot.

Source code.

#include<xc.h>
// PIC16F887 Configuration Bit Settings
// CONFIG1
#pragma config FOSC = XT
#pragma config WDTE = OFF
#pragma config PWRTE = OFF
#pragma config MCLRE = ON
#pragma config CP = OFF
#pragma config CPD = OFF
#pragma config BOREN = ON
#pragma config IESO = ON
#pragma config FCMEN = ON
#pragma config LVP = ON
// CONFIG2
#pragma config BOR4V = BOR40V
#pragma config WRT = OFF
#define _XTAL_FREQ 4000000
char letterA[8]={0x10,0x38,0x6C,0xC6,0xC6,0xFE,0xC6,0xC6};
char dotControl[8]={1,2,4,8,16,32,64,128};
void driveMatrix(){
  for (int i=0;i<8;i++)
  {
   PORTD=0x00;
   PORTC=letterA[i];
   PORTD=dotControl[i];
   __delay_ms(1);
  }
}
void main(){
    /*Clear PortC*/
    PORTC=0x00;
    /*Clear PortD*/
    PORTD=0x00;
    /*PortC output*/
    TRISC=0x00;
    /*PortD output*/
    TRISD=0x00;
    while(1) driveMatrix();
}

Here's a screen shot of running program.

Driving a single 8x8 dot matrix display using PIC16F887
A running simulation.
The matrix display letter 'A'.

No comments:

Post a Comment

320x50

Search This Blog

tyro-728x90