View previous topic :: View next topic |
Author |
Message |
Guest
|
from 16F84 to 16F88 no longer works |
Posted: Sat Oct 10, 2009 10:21 am |
|
|
Hi, I'm using an LCD display and 16F84A.
I upgrade with 16F88 cause I want display an analogic value on the LCD, but no longer works. (with 16f84a this software works). Why?
I have an interrupt every ms.
Code: | #include <16F88.h>
#fuses XT, NOWDT
#use delay(clock = 4000000)
#define uscita0 PIN_B0
#include "flex_lcd.c"
int clock, clock2;
int16 tempo, tempo2, numero;
//--------------------------------------------------------------------------
#int_RTCC
RTCC_isr() //Interrupt Service Routine 1000 Hz
{
set_timer0(135);
tempo++;
if (tempo>999) {
tempo=0;
clock=1; //bit con periodo 1s
}
tempo2++;
if (tempo2>499) {
tempo2=0;
clock2=!clock2; //bit con periodo 1s
}
}
//--------------------------------------------------------------------------
void main() { //inizio programma principale
set_tris_a(0x10); //0001 0000 RA7 RA6 RA5 RA4 RA3 RA2 RA1 RA0
set_tris_b(0x00);
set_timer0(135);
setup_timer_0 (RTCC_INTERNAL|RTCC_DIV_8);
enable_interrupts(int_rtcc);
enable_interrupts(global);
tempo=0;
tempo2=0;
numero=0;
clock=0;
clock2=1;
lcd_init();
while(1) //ciclo continuo-------------------------------------------------
{
if (clock) {
printf(lcd_putc, "\fseconds=%lu", numero); //%3.2f per i float es. 123.00
numero++;
clock=0;
}
output_bit(uscita0, clock2);
} //fine ciclo while
} //fine main
|
|
|
|
webgiorgio
Joined: 02 Oct 2009 Posts: 123 Location: Denmark
|
|
Posted: Sat Oct 10, 2009 10:22 am |
|
|
Sorry, I was not logged in when I opened the topic... |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Sat Oct 10, 2009 1:38 pm |
|
|
Quote: | but no longer works |
Explain this in detail. What does it do when it works ? What is it doing now ? |
|
|
webgiorgio
Joined: 02 Oct 2009 Posts: 123 Location: Denmark
|
|
Posted: Sat Oct 10, 2009 2:59 pm |
|
|
There is a led on RB0 that must turn on and off each second.
The lcd show "second=1" "second=2" "second=3" "second=4" ....and so on.
When I use a 16F84A all works as explained, but if I use a 16F88, changing the #include obviously before compile, the led stays off (or sometimes on flickering, or do some blink before go off) and the display stays empty. |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Sun Oct 11, 2009 1:56 pm |
|
|
Quote: | #include "flex_lcd.c" |
1. Post the #define statements in the flex_lcd.c file that show the pin
numbers used by the LCD.
2. Post your compiler version.
3. Is the test with the 16F88 being done on a different board, or is
it the same board as with the 16F84A ?
4. Is this test being done on a real hardware board, or is this Proteus ? |
|
|
Ttelmah Guest
|
|
Posted: Sun Oct 11, 2009 2:55 pm |
|
|
Don't I have a 'niggling' memory, that on the F88, the comparator wakes up enabled?.
Best Wishes |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Sun Oct 11, 2009 3:00 pm |
|
|
It's off on power-up and the CCS start-up code also turns it off.
But, there could be a problem in his version. I won't know until he
posts his version number. |
|
|
webgiorgio
Joined: 02 Oct 2009 Posts: 123 Location: Denmark
|
|
Posted: Mon Oct 12, 2009 1:26 am |
|
|
Code: | #define LCD_DB4 PIN_B4
#define LCD_DB5 PIN_B5
#define LCD_DB6 PIN_B6
#define LCD_DB7 PIN_B7
#define LCD_E PIN_B3
#define LCD_RS PIN_B2
#define LCD_RW PIN_RW //not used
//#define USE_LCD_RW 1
//========================================
#define lcd_type 2 // 0=5x7, 1=5x10, 2=2 lines
#define lcd_line_two 0x40 // LCD RAM address for the 2nd line
|
Compiler version: PCW, IDE 3.32, PCB 3.160, PCM 3.160.
Is the same real hardware board (a bread board). |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Mon Oct 12, 2009 1:50 am |
|
|
Quote: |
#include <16F88.h>
#fuses XT, NOWDT
Compiler version: PCM 3.160
|
You need to add the NOLVP fuse. In vs. 4.xxx, the compiler defaults
to NOLVP if it's not specified, but in vs. 3.160 it defaults to LVP.
This can cause the PIC to lock-up if pin B3 goes to a high level.
Add the fuse shown in bold below:
Quote: | #include <16F88.h>
#fuses XT, NOWDT,NOLVP
|
|
|
|
webgiorgio
Joined: 02 Oct 2009 Posts: 123 Location: Denmark
|
|
Posted: Mon Oct 12, 2009 1:16 pm |
|
|
software run! The led blink correctly, but the LCD stay empty. :(
Software is ok because all works under 16F84A.
Looking to the 16f88 datasheet I can see that RA3 5 6 7 have a different output circuit compared with the same pins under 16f84a (that have something like a tri-state output).
Maybe the 16f88 need some pull-up resistor or a special I/O configuration?
sorry, it is my first time with 16F88.
thank you |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Mon Oct 12, 2009 1:35 pm |
|
|
You are using pins B6 and B7 for the LCD. Those pins are used by
the ICD debugger. You must disconnect the debugger from the board
for the LCD to run properly. (Or use different pins, instead of those two). |
|
|
webgiorgio
Joined: 02 Oct 2009 Posts: 123 Location: Denmark
|
|
Posted: Sat Oct 17, 2009 2:32 am |
|
|
I'm not using debugging hardware.
I remove the pic from the board and I place it on the zif socket in the programmer to program.
I try connecting some led to understand how the output circuit works.
Looking at the datasheet, the output circuit of B0 B3 B5 B6 B7 seem the same. But connecting a led from +5V to B0 it blink well, but not on B6 or B7. (changing the software before obviously)
On RB6 and RB7 when the output is 1 there is a connection to +5V, when is 0 the output is NOT connected to GND.
Instead on B0, when the output is 0 there is a connection to GND, and the led can turn on shining.
Using B0 B1 instead of B6 B7 the LCD works.
But I can't understand why just looking the datasheet! |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Sun Oct 18, 2009 3:26 pm |
|
|
Describe the circuits connected to pins B6 and B7. Give the connections
and the component values. For example, if using a resistor, give the
resistance value in ohms. If using an LED, post what is connected to
the anode pin, and to the cathode pin of the LED. |
|
|
webgiorgio
Joined: 02 Oct 2009 Posts: 123 Location: Denmark
|
|
Posted: Mon Oct 19, 2009 5:49 am |
|
|
LCD Working configuration:
Code: |
#define LCD_DB4 PIN_B4
#define LCD_DB5 PIN_B5
#define LCD_DB6 PIN_B1
#define LCD_DB7 PIN_B0
#define LCD_E PIN_B3
#define LCD_RS PIN_B2
|
led test with LCD working connection solution:
good working LED connection
RB6----A-led-K---R----GND
The led turn on and off
Not well working LED connection
RB6----K-led-A---R----+5V
The led turn on and "on with less brightness".
PIC autoreset in 3-5 seconds after start.
LCD not working configuration:
Quote: | #define LCD_DB4 PIN_B4
#define LCD_DB5 PIN_B5
#define LCD_DB6 PIN_B6
#define LCD_DB7 PIN_B7
#define LCD_E PIN_B3
#define LCD_RS PIN_B2 |
|
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Mon Oct 19, 2009 11:20 am |
|
|
Quote: | Not well working LED connection
RB6----K-led-A---R----+5V
The led turn on and "on with less brightness".
PIC autoreset in 3-5 seconds after start. |
What is the resistor value 'R' (in ohms) ? |
|
|
|