|
|
View previous topic :: View next topic |
Author |
Message |
gesingle
Joined: 12 Oct 2009 Posts: 2
|
LCD Programming on PIC16F193X |
Posted: Mon Oct 12, 2009 2:44 pm |
|
|
I am trying to program the PIC16F1934 to drive an LCD using the CCS setup_lcd() and lcd_symbol() functions. I'm starting with the ex_92lcd.c example supplied with the PCM compiler. The program compiles but hangs at the disassembled command BTFSS 0xe, 0x4 in lcd_symbol(). Are the CCS internal LCD controller functions compatible with the PIC16F193X? 0x0E is Bank0/PORTC in the PIC16F193X and TMR1L in the PIC16C9XX. |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Mon Oct 12, 2009 4:13 pm |
|
|
Post a very short test program (like 10 lines in main) that shows the
problem. It must be compilable. It must have the #include for the PIC,
#fuses, #use delay, and variable declarations.
Post your compiler version. |
|
|
gesingle
Joined: 12 Oct 2009 Posts: 2
|
|
Posted: Mon Oct 12, 2009 5:14 pm |
|
|
CCS PCM C Compiler, Version 4.092
MPLAB IDE v8.30
MPLAB ICD 3
PIC16F1934-I/P on breadboard
Code: | // LCD test driver for PIC16F1934-I/P
// derived from ex_92lcd.c
#include <16F1934.h>
#device ICD=TRUE
#fuses INTRC_IO, NOWDT, PUT, NOPROTECT, BROWNOUT, NOLVP, CLKOUT
#fuses DEBUG
#use delay(internal=8M)
#define DIGIT3 COM0+23, COM0+22, COM0+21, COM0+20, COM0+19, COM0+18, COM0+17, COM0+16
#define DIGIT2 COM0+15, COM0+14, COM0+13, COM0+12, COM0+11, COM0+10, COM0+9, COM0+8
#define DIGIT1 COM0+7, COM0+6, COM0+5, COM0+4, COM0+3, COM0+2, COM0+1, COM0+0
byte const Digit_Map[10] = {0xC7,0x03,0xAD,0xA7,0x63,0xE6,0xEE,0x83,0xEF,0xE7};
#define BLANK 0
/////////////////////////////////////////////////////////////////////////////////////////
byte lcd_pos;
void lcd_putc(char c)
{
byte segments;
if(c=='\f')
lcd_pos=0;
else
{
if((c>='0')&&(c<='9'))
segments=Digit_Map[c-'0'];
else
segments=BLANK;
switch(lcd_pos)
{
case 1 : // fill 100s place
lcd_symbol(segments,DIGIT3); // <-- hangs on this call
// ****** Disassembly listing
// 02E 0022 MOVLB 0x2
// 02F 1E0E BTFSS 0xe, 0x4 --- hangs here
// 030 282F GOTO 0x2f --- hangs here
// 031 0020 MOVLB 0
// ******
break;
case 2 : // fill 10s place
lcd_symbol(segments,DIGIT2);
break;
case 3 : // fill 1s place
lcd_symbol(segments,DIGIT1);
break;
}
}
lcd_pos++;
}
void main()
{
long number = 0;
setup_lcd(LCD_STATIC,2);
while(TRUE)
{
printf(lcd_putc,"\f%4lu",number);
if(number++==1000)
number=0;
delay_ms(100);
}
} |
|
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Mon Oct 12, 2009 6:03 pm |
|
|
The lcd_symbol() function is buggy in your version of the compiler
for the 16F1934. It's using the wrong RAM bank address for the LCDPS
register. It's supposed to test the WA bit in the LCDPS register, but
because the address is wrong, it's testing bit 4 of the LATC register.
That's why it hangs.
The bug still exists in vs. 4.099. There may be other register address
bugs in 4.099. I didn't check. |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|