Hallo,

Ik ben begonnen met het programmeren van een PIC16F916. Ik ben begonnen met het begin, namelijk het laten knipperen van een led wat gelukt is. Nu wil ik een LCD laten werken (DG12232 met sed1520 controller). Dit lukt jammer genoeg niet.
Ik ben 100% zeker van de pin-connecties. Ik heb deze x-maal gecontroleerd.
Het speciale aan deze LCD is dat er een externe clock noodzakelijk is (2khz). Deze maak ik aan de hand van een PWM uitgang die aanwezig is op de chip. De frequentie heb ik berekend dankzij deze site: http://www.micro-examples.com/public/microex-navig/doc/097-pwm-calcula….
De code van het hoofdprogramma ziet er als volgt uit:


#include <htc.h>

__CONFIG(FOSC_INTOSCIO & WDTE_OFF & PWRTE_ON & MCLRE_OFF & CP_OFF & CPD_OFF & BOREN_OFF & IESO_OFF & FCMEN_OFF & DEBUG_OFF);

#define _XTAL_FREQ 8000000

#define	LCD_CS2  RA0		// output 	LCD Chip Select 1
#define	LCD_CS1	 RA1		// output 	LCD Chip Select 2
#define	LCD_A0   RA2		// output  	LCD A0
#define	LCD_RW   RA3		// output 	LCD Read/Write
#define LCD_E	 RA4		// output 	LCD Enable (data strobe)
	
//RC5 is de PWM uitgang, hieraan hangt CLK van lcd	
	
#define C0  RB0		// input & output - Data bus to LCD
#define C1  RB1		// input & output - Data bus to LCD
#define C2  RB2		// input & output - Data bus to LCD
#define C3  RB3		// input & output - Data bus to LCD
#define C4  RB4		// input & output - Data bus to LCD
#define C5  RB5		// input & output - Data bus to LCD
#define C6  RB6		// input & output - Data bus to LCD
#define C7  RB7		// input & output - Data bus to LCD
	
#define LCD_DATA 	PORTB	// Data port for the LCD
#define LCD_DATA_TRIS	TRISB	// and its associated direction register	

#include "SG12232A_Driver_1_0.h"	// this is the LCD driver
#include "glcd_library_1_0.h"		// and this is a universal graphics/fonts package


/**********************************************************************************************
Main program
**********************************************************************************************/
void glcd_init(void)
{
	unsigned char chip;
	for(chip = 0; chip < 2; chip++) {
		// Setup the chip.  Most commands are not required but are included in case a future version of
		// the LCD will have different defaults.  The only command that is mandatory is DISPLAY_ON.
		glcd_WriteCommand(RESET, chip);
		glcd_WaitForStatus(0x10, chip);
		glcd_WriteCommand(ADC_CLOCKWISE, chip);
		glcd_WriteCommand(STATIC_DRIVE_OFF, chip);
		glcd_WriteCommand(END_READ_MODIFY, chip);
		glcd_WriteCommand(DUTY_RATIO_32, chip);
		glcd_WriteCommand(DISPLAY_ON, chip);				// mandatory
		glcd_WriteCommand(DISPLAY_START_LINE | 0, chip);
	}
	glcd_fillscreen(0);
}

void main() 
{	
	OSCCON = 0b01110001;
	CMCON0 = 0b00000111;
	ANSEL = 0b00000000;	
	TRISA = 0b00000000;		// this MUST agree with the #defines below
	TRISC = 0b00000000;		// this MUST agree with the #defines below
	PORTC = 0b00000000;

PR2 = 0b11111001;
T2CON = 0b00000101;
CCPR1L = 0b01111100;
CCP1CON = 0b00111100;

LCD_CS1 = LCD_CS2 = LCD_A0 = 1;
LCD_RW = LCD_E = 0;
	
glcd_init();			// defined in SG12232A_Driver.h
glcd_setxy(0, 0, 1, 1);		// defined in glcd_library.h

while(1) {
glcd_fillscreen(0);
__delay_ms(250);
__delay_ms(250);
__delay_ms(250);
__delay_ms(250);
glcd_fillscreen(1);
__delay_ms(250);
__delay_ms(250);
__delay_ms(250);
__delay_ms(250);
}
}

Wat ik hier probeer te doen is alle pixels oplichten en dan weer doven om de 1sec.

dit staat in de driver van het display die ik ergens op internet gevonden heb en lichtjes aangepast heb om deze te kunnen gebruiken met HITECH C:

/*********************************************************************************
   DRIVER FOR 122x32 SG12232A graphics LCD FROM altronics.com.au
   Using the SED1520 chipset

   Ver 1.0 - Apr 09 - Original version

   Copyright 2009 Geoff Graham - http://geoffg.net
   This program is free software: you can redistribute it and/or modify it under the terms of the GNU General
   Public License as published by the Free Software Foundation, either version 2 of the License, or (at your
   option) any later version.

   This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the
   implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   for more details.  You should have received a copy of the GNU General Public License along with this program.
   If not, see <http://www.gnu.org/licenses/>.
   
   For more details and programming notes go to http://geoffg.net/SG12232A
   
   This code is derived from code for the SED1520 by Radoslaw Kwiecien (en.radzio.dxp.pl)

   Target/Development environment:
   	- Microchip PIC microcontroller chips
   	- Microchip MPLAB V8 or later
   	- CCS C Compiler V4 or later (tested)
   	- HiTech C Compiler (not tested)
   	
************************************************************************************
   	
   This driver exposes the following functions and defines.

   glcd_init()
      * Initialises the display
      * Must be called before any other function.

   glcd_pixel(x,y,colour)
      * Sets the pixel to the given colour.
        - origin (x=0, y=0) is top left corner
        - colour can be ON or OFF (0 or 1)

   glcd_fillScreen(colour)
      * Fills the entire LCD with the given colour.
        - colour can be ON or OFF (0 or 1)

   GLCD_GRAPHICS_WIDTH = 122     Width of display
   GLCD_GRAPHICS_HEIGHT = 32     Height of display

************************************************************************************

	The following pins must be defined
		LCD_CS2		 output 	LCD Chip Select 1
		LCD_CS1		 output 	LCD Chip Select 2
		LCD_A0		 output  	LCD A0
		LCD_RW		 output 	LCD Read/Write
		LCD_E		 output		LCD Enable
	
	These should be defined as a writable bit corresponding to the pin on the chip
	For example, in CCS C:
		#byte 	porta = 5					// Port A I/O register
		#bit	LCD_CS2 = porta.0			// RA0 (i.e.  Port A bit 0)
	Or, in HiTech C:
		#define	LCD_CS2   RA0
	
	The 8 bit port used for the data bus must be defined as LCD_DATA 
	and its associated tris register as LCD_DATA_TRIS
	
	For example, in CCS C:
		#byte LCD_DATA = 7			// port c register
		#byte LCD_DATA_TRIS = 0x87	// port c tris register

The control pins (LCD_CS2, etc) must set to outputs before calling glcd_init()
The data port (LCD_DATA) is controlled within this driver and does not need to be set

Finally, in CCS C the ports used should be set to fast I/O.  For example:
	#use fast_io(A)	
	#use fast_io(C)


************************************************************************************/

#define DISPLAY_ON 0xAF
#define DISPLAY_OFF 0xAE
#define DISPLAY_START_LINE 0xC0
#define PAGE_ADDRESS_SET 0xB8
#define COLUMN_ADDRESS_SET 0x00
#define ADC_CLOCKWISE 0xA0
#define ADC_COUNTERCLOCKWISE 0xA1
#define STATIC_DRIVE_ON 0xA5
#define STATIC_DRIVE_OFF 0xA4
#define DUTY_RATIO_16 0xA8
#define DUTY_RATIO_32 0xA9
#define READ_MODIFY_WRITE 0xE0
#define END_READ_MODIFY 0xEE
#define RESET 0xE2

#define SCREEN_WIDTH	122
#define SCREEN_HEIGHT 32

#define TRIS_OUTPUT			0
#define TRIS_INPUT			0xff

//-------------------------------------------------------------------------------------------------
// Wait for a status bit to come true.  Will wait forever (no timeout)
//-------------------------------------------------------------------------------------------------
unsigned char tmp1;

void glcd_WaitForStatus(unsigned char status, unsigned char chip) {
	unsigned char tmp;
	
	LCD_A0 = 0; 							// select control
	LCD_DATA_TRIS = TRIS_INPUT; 			// and set our port direction
	LCD_RW = 1; 							// tell the LCD to take control of the data lines
	
	do {
	  if(chip == 0) 						// set the chip
		LCD_CS1 = 0; 
	  else 
		LCD_CS2 = 0; 
		
		LCD_E = 1;
		LCD_A0 = 0; 						// this is essentially a nop to provide an access delay
		tmp = LCD_DATA; 					// get the status
		LCD_E = 0;
		LCD_CS1 = LCD_CS2 = 1; 				// deselect whatever chip was selected in the beginning
	  }while(tmp & status);
	  
	LCD_RW = 0; 							// tell the LCD to release the data lines
	LCD_DATA_TRIS = TRIS_OUTPUT; 			// and set the port direction to output
}


//-------------------------------------------------------------------------------------------------
// Write a command
//-------------------------------------------------------------------------------------------------
void glcd_WriteCommand(unsigned char commandToWrite, unsigned char chip) {
	glcd_WaitForStatus(0x80, chip);
	
	LCD_A0 = 0;
	
	LCD_DATA = commandToWrite;
	LCD_RW = 0;
	
	if(chip == 0) 							// set the chip
		LCD_CS1 = 0; 
	else 
		LCD_CS2 = 0; 

	LCD_E = 1;
	LCD_A0 = 0; 							// this is essentially a nop to provide an access delay
	LCD_E = 0;
	LCD_CS1 = LCD_CS2 = 1; 					// deselect whatever chip was selected in the beginning
}


//-------------------------------------------------------------------------------------------------
// Position for the next read/write from/to the LCD display memory
// Note that x and y are byte locations, not pixel addresses
//-------------------------------------------------------------------------------------------------
void glcd_goto(unsigned char x, unsigned char y) {
	if(x < (SCREEN_WIDTH/2)) {
		glcd_WaitForStatus(0x80, 0); 					// wait for the chip
		glcd_WriteCommand(COLUMN_ADDRESS_SET | x, 0);
		glcd_WriteCommand(PAGE_ADDRESS_SET | y, 0);
	} else {
		glcd_WaitForStatus(0x80, 1); 					// wait for the chip
		glcd_WriteCommand(COLUMN_ADDRESS_SET | (x - (SCREEN_WIDTH/2)), 1);
		glcd_WriteCommand(PAGE_ADDRESS_SET | y, 1);
	}
}


//-------------------------------------------------------------------------------------------------
// Write a data byte
//-------------------------------------------------------------------------------------------------
void glcd_WriteData(unsigned char x, unsigned char y, unsigned char dataToWrite) {

	glcd_goto(x, y);						// position for the write

	LCD_A0 = 1; 
	LCD_RW = 0; 
	
	LCD_DATA = dataToWrite; 
	
	if(x < (SCREEN_WIDTH/2))			// select the correct chip
	  	LCD_CS1 = 0;
	else
	    LCD_CS2 = 0;
	
	LCD_E = 1;								// strobe the data
	LCD_A0 = 1; 							// this is essentially a nop to provide an access delay
	LCD_E = 0;
	LCD_CS1 = LCD_CS2 = 1; 					// deselect whatever chip was selected in the beginning
}


//-------------------------------------------------------------------------------------------------
// Read a data byte from the LCD
//-------------------------------------------------------------------------------------------------
void glcd_ReadData(unsigned char x, unsigned char y) {
//	unsigned char tmp;
	
	glcd_goto(x, y);						// position for the read
	
	LCD_A0 = 1; 							// select data
	LCD_DATA_TRIS = TRIS_INPUT; 			// and set our port direction
	LCD_RW = 1; 							// tell the LCD to take control of the data lines
	
	if(x < (SCREEN_WIDTH/2))			// select the correct chip
	  	LCD_CS1 = 0;
	else
	    LCD_CS2 = 0;
	
	LCD_E = 1;								// for some reason this series of chips needs a dummy read first
	// insert a 100uS delay here if your cpu is faster than 40MHz				
	LCD_E = 0;
	// insert a 100uS delay here if your cpu is faster than 40MHz				
	
	LCD_E = 1;								// now the real read
	// insert a 100uS delay here if your cpu is faster than 40MHz		
	tmp1 = LCD_DATA; 						// get the data
	LCD_E = 0;
	LCD_RW = 0;								// we will take control of the data bus
	LCD_DATA_TRIS = TRIS_OUTPUT; 			// and set the port direction accordingly
	LCD_CS1 = LCD_CS2 = 1; 					// deselect whatever chip was selected in the beginning
	
//	return;
//	return tmp;
}



//-------------------------------------------------------------------------------------------------
// 
//-------------------------------------------------------------------------------------------------
void glcd_fillscreen(unsigned char colour) {
	char j, i, c;
	if(colour)
		c = 0xff;
	else
		c = 0;
	for(j = 0; j < SCREEN_HEIGHT/8; j++)
	  for(i = 0; i < SCREEN_WIDTH; i++);	
			glcd_WriteData(i, j, c);
}


//-------------------------------------------------------------------------------------------------
//
//-------------------------------------------------------------------------------------------------
void glcd_pixel(unsigned char x, unsigned char y, unsigned char colour) {
	unsigned char temp;
	if(x >= SCREEN_WIDTH || y >= SCREEN_HEIGHT) return;
//	temp = glcd_ReadData(x, y/8); 
	glcd_ReadData(x, y/8);
	temp = tmp1;           //temp1 wordt gevuld in glcd_Readdata
	if(colour)
	  glcd_WriteData(x, y/8, temp | (1 << (y % 8))); 
	else
	  glcd_WriteData(x, y/8, temp & ~(1 << (y % 8))); 
}



//-------------------------------------------------------------------------------------------------
// Initialise the display
// Only needs to be called once at the start of the program
//-------------------------------------------------------------------------------------------------
/*void glcd_init(void)
{
	unsigned char chip;
	for(chip = 0; chip < 2; chip++) {
		// Setup the chip.  Most commands are not required but are included in case a future version of
		// the LCD will have different defaults.  The only command that is mandatory is DISPLAY_ON.
		glcd_WriteCommand(RESET, chip);
		glcd_WaitForStatus(0x10, chip);
		glcd_WriteCommand(ADC_CLOCKWISE, chip);
		glcd_WriteCommand(STATIC_DRIVE_OFF, chip);
		glcd_WriteCommand(END_READ_MODIFY, chip);
		glcd_WriteCommand(DUTY_RATIO_32, chip);
		glcd_WriteCommand(DISPLAY_ON, chip);				// mandatory
		glcd_WriteCommand(DISPLAY_START_LINE | 0, chip);
	}
	glcd_fillscreen(0);
}
*/

Ik zoek hier al dagen op zonder de fout te vinden... Ziet iemand hier het probleem?
Of heeft iemand een sed1520 schermpje aan de praat gekregen met een microcontroller waarvan ik de code eens kan bekijken?

alvast bedankt voor jullie reactie!