P10(1R)706 interfacing with PIC16F1939 microcontroller

The Dot Matrix Display (DMD) is a 32x16 array of high-brightness LEDs for visually striking effects. [Product Page]
Post Reply
pravin
Posts: 1
Joined: Sun Jul 17, 2016 7:27 am

P10(1R)706 interfacing with PIC16F1939 microcontroller

Post by pravin » Sun Jul 17, 2016 7:41 am

Hello Friends I just borrowed a DMD display from one of my friend, to make it work by myself. So far I am able to understand the hardware part of it like pinout and basic SPI working. But still I am lacking to display anything on it. My display just goes blank even after sending the data, i have followd the everything mentioned here viewtopic.php?t=5754 in DMD Notes.
I preassumed that P10(1R)706 works same as its descendants. I am hereby attaching my code for reference....please anybody help me find what i am missing?
My main() function

Code: Select all

#include <htc.h>
#include "include.h"

// PIC16F1939 Configuration Bit Settings
__CONFIG(FOSC_INTOSC & WDTE_OFF & PWRTE_ON & MCLRE_ON & CP_OFF & CPD_OFF & BOREN_OFF & CLKOUTEN_OFF & IESO_OFF & FCMEN_OFF);
__CONFIG(WRT_OFF & VCAPEN_OFF & PLLEN_ON & STVREN_ON & BORV_LO & LVP_OFF);

//                                a    b    c    d                     
unsigned char dmdbuff[16][4]={//C0    C1   C2   C3
                                {0x00,0x00,0x00,0x00},  //R0
                                {0x00,0x00,0x00,0x00},  //R1
                                {0x00,0x00,0x00,0x00},  //R2
                                {0x00,0x00,0x00,0x00},  //R3
                                {0x00,0x00,0x00,0x00},  //R4
                                {0x00,0x00,0x00,0x00},  //R5
                                {0x00,0x00,0x00,0x00},  //R6
                                {0x00,0x00,0x00,0x00},  //R7
                                {0x00,0x20,0x00,0x04},  //R8
                                {0x38,0x20,0x38,0x04},  //R9
                                {0x44,0x2c,0x44,0x34},  //R10
                                {0x04,0x32,0x40,0x4c},  //R11
                                {0x3c,0x22,0x40,0x44},  //R12
                                {0x44,0x32,0x40,0x44},  //R13
                                {0x44,0x32,0x44,0x4c},  //R14
                                {0x38,0x2c,0x38,0x34},  //R15 
                            };

char row,x,y;
void main()
{
    system_init();
    while(1)
    {        
        show_row(0);        
        show_row(1);
        show_row(2);
        show_row(3); 
    }
}


void system_init()
{
    OSCCON  = 0b01110000;   // 32 MHz Fosc w/ PLLEN_ON (config bit) 
    TRISC=0b00000000;
//    PORTC=0;
    TRISD0=0;
    pin=0;
//    USART_Init();
//    ms1_delay(100);
//    USART_putstring("UART_OK\r");
    swspi_init();
}

void show_row(char temp)
{        
    for(y=0;y<=3;y++)
    {
        swspi_write_byte(dmdbuff[(16-4)+temp][y]); 
        swspi_write_byte(dmdbuff[(16-8)+temp][y]);
        swspi_write_byte(dmdbuff[(16-12)+temp][y]);
        swspi_write_byte(dmdbuff[(16-16)+temp][y]);               
    }
    
    P10_LATCH=1;
    us500_delay(1);
    P10_LATCH=0;
    
    scan_row(temp); 
    
    DISP_EN=0;    
}

void scan_row(char temp)
{
    switch(temp)
    {
        case 0: P10_A=0;
                P10_B=0;
            break;
        case 1: P10_A=1;
                P10_B=0;
            break;
        case 2: P10_A=0;
                P10_B=1;
            break;
        case 3: P10_A=1;
                P10_B=1;
            break;
        default:P10_A=0;
                P10_B=0;
            break;            
    }
}

void ms1_delay(unsigned int c)          
{
    unsigned int i,j;
    for(i=1;i<=c;i++)
        for(j=0;j<=568;j++);
}

void us500_delay(unsigned int c)          
{
    unsigned int i,j;
    for(i=1;i<=c;i++)
        for(j=0;j<=284;j++);
}

void interrupt my_ISR()
{
    if(RCIF)
    {
        USARTdataready=1;
        rx_byte=RCREG;
        if(FERR || OERR)
            CREN=0;
        USART_putchar(rx_byte);
        RCIF=0;
        get_data();          
    }
}
my spi routine
spi routine

Code: Select all

void swspi_init( void )
{
    P10_A=0;
    P10_B=0;
    P10_PWM=0;
    P10_SCK=0;
    DISP_EN=1;    
    P10_DATA=0;
    P10_LATCH=0;
}

/*************************************
write value to register
**************************************/
void swspi_write_byte(unsigned int temp)
{
	unsigned char n=8;
//    DISP_EN = 0;

//	temp |= 0x80;

//  	P10_SCK = 0;
  	while(n--)
   	{
        if(temp&0x80)
      		P10_DATA=1;
     	else
      		P10_DATA=0;
              
        P10_SCK = 1;
        temp <<= 1;		
        P10_SCK = 0;
        NOP();
   	}
	NOP();
//	DISP_EN = 1;	
}
Pin assignements

Code: Select all

#define  P10_A    	RC0
#define  P10_B    	RC1
#define  P10_PWM	RC2
#define  P10_SCK	RC3
#define  DISP_EN    	RC4
#define  P10_DATA 	RC5
#define  P10_LATCH	RC6
Image

in the along with image, what should be the order of sending bytes to display??? Currently I am sending as :
call of showrow(0):DisplayRam[12][0]>DisplayRam[8][0]>DisplayRam[4][0]>DisplayRam[0][0]>DisplayRam[13][0]>DisplayRam[9][0]>DisplayRam[5][0]>DisplayRam[1][0]>DisplayRam[14][0]>DisplayRam[10][0]>DisplayRam[6][0]>DisplayRam[2][0]>DisplayRam[15][0]>DisplayRam[11][0]>DisplayRam[7][0]>DisplayRam[3][0]
call of showrow(1):DisplayRam[12][1]>DisplayRam[8][1]>DisplayRam[4][1]>DisplayRam[0][1]>DisplayRam[13][1]>DisplayRam[9][1]>DisplayRam[5][1]>DisplayRam[1][1]>DisplayRam[14][1]>DisplayRam[10][1]>DisplayRam[6][1]>DisplayRam[2][1]>DisplayRam[15][1]>DisplayRam[11][1]>DisplayRam[7][1]>DisplayRam[3][1]
& so on....
Am I following the right procedures?
Thanks.

Brissieboy
Posts: 181
Joined: Fri Sep 20, 2013 7:25 am

Re: P10(1R)706 interfacing with PIC16F1939 microcontroller

Post by Brissieboy » Fri Jul 22, 2016 3:13 am

pravin,
Have a look at this thread this thread. It gives a bit of detail on the DMD and may help you out.

Post Reply