View previous topic :: View next topic |
Author |
Message |
blak3r
Joined: 11 Jan 2004 Posts: 45
|
Circuit doesn't give proper output when ICD is attached! |
Posted: Sat Oct 02, 2004 3:13 pm |
|
|
In my program the first thing i do is initialize an LCD and then print
"Firmware Rev. #xxx"
When the ICD is attached i will get various outputs on the LCD. Most of the time the first five letters of firmware get cut off and the rest of it is fine so it looks like "are Rev. #xxx". If i don't have the ICD attached i don't have this problem.
I have the PUT enabled and i've put large delays after lcd initialization and even before i attempt to initialize the lcd.
My VDD w/o the ICD is 4.75V and my voltage w/ is 4.61. I'm using a benchtop power supply which is capable of supplying enough power to my circuit. I also measured the current being drawn to be 130mA w/o ICD and 226mA w/ ICD. That seems like a lot of current for the ICD to be drawing in an idle state.
The circuit i've been working on was pretty reliable a month ago. I had to put the project aside for about a month. So, if anything i believe a component possibly is defective. Any ideas as to what this might be? I figured i'd ask before i dismantled my circuit. (I have to remove the lcd assembly and a few other things to get to the PIC)
Thanks for any insights...
~blake _________________ "Everything should be made as simple as possible, but not one bit simpler" -- Albert Einstein
http://www.blakerobertson.com |
|
|
Mark
Joined: 07 Sep 2003 Posts: 2838 Location: Atlanta, GA
|
|
Posted: Sat Oct 02, 2004 4:52 pm |
|
|
Your circuit doesn't use RB6 or RB7 does it? (the ICD connections) |
|
|
blak3r
Joined: 11 Jan 2004 Posts: 45
|
|
Posted: Sun Oct 03, 2004 12:13 pm |
|
|
yes it does for the lcd. hmmm.... but i'm not trying to use the debugger. I'm loading the program with the ICD just as an ICSP.
~blake _________________ "Everything should be made as simple as possible, but not one bit simpler" -- Albert Einstein
http://www.blakerobertson.com |
|
|
Haplo
Joined: 06 Sep 2003 Posts: 659 Location: Sydney, Australia
|
|
Posted: Sun Oct 03, 2004 4:48 pm |
|
|
Do you have any code located at the last 400 bytes of the flash memory? |
|
|
Mark
Joined: 07 Sep 2003 Posts: 2838 Location: Atlanta, GA
|
|
Posted: Sun Oct 03, 2004 7:13 pm |
|
|
Quote: |
yes it does for the lcd. hmmm.... but i'm not trying to use the debugger. I'm loading the program with the ICD just as an ICSP.
|
Then you should unplug it when you are done programming |
|
|
Haplo
Joined: 06 Sep 2003 Posts: 659 Location: Sydney, Australia
|
|
Posted: Sun Oct 03, 2004 7:17 pm |
|
|
Mark wrote: | Quote: |
yes it does for the lcd. hmmm.... but i'm not trying to use the debugger. I'm loading the program with the ICD just as an ICSP.
|
Then you should unplug it when you are done programming |
But according to his first post it seems he programs the circuit with the ICD and then hits RUN. This sould be ok.
He may have some code at the end of the memory which maybe overwritten by the ICD debugging code.
And also, what ICD are you using? Your ICD seems to me drawing way too much current. |
|
|
Mark
Joined: 07 Sep 2003 Posts: 2838 Location: Atlanta, GA
|
|
Posted: Sun Oct 03, 2004 8:45 pm |
|
|
Quote: |
But according to his first post it seems he programs the circuit with the ICD and then hits RUN |
Quote: |
but i'm not trying to use the debugger. I'm loading the program with the ICD just as an ICSP
|
|
|
|
Haplo
Joined: 06 Sep 2003 Posts: 659 Location: Sydney, Australia
|
Re: Circuit doesn't give proper output when ICD is attached! |
Posted: Mon Oct 04, 2004 2:00 am |
|
|
blak3r wrote: | In my program the first thing i do is initialize an LCD and then print "Firmware Rev. #xxx"
When the ICD is attached i will get various outputs on the LCD. Most of the time the first five letters of firmware get cut off and the rest of it is fine so it looks like "are Rev. #xxx". If i don't have the ICD attached i don't have this problem. |
This shows that he is indeed running the code under ICD. Otherwise nothing would appear on the LCD.
I think by "but i'm not trying to use the debugger. I'm loading the program with the ICD just as an ICSP " he means he is not setting any breakpoints/stopping the code and debugging it. He is just hitting run and watching it go. |
|
|
blak3r
Joined: 11 Jan 2004 Posts: 45
|
|
Posted: Mon Oct 04, 2004 3:30 am |
|
|
Haplo is correct. Using the ICD as a debugger sure would be nice but i gave up on it a while ago as it's been really unstable.
I don't think i'm using any code in the last 400 bytes of flash. Why would it matter? Here's the statistics:
ROM used: 2644 (32%)
2048 (25%) including unused fragments
1 Average locations per line
3 Average locations per statement
RAM used: 120 (69%) at main() level
162 (93%) worst case
Lines Stmts % Files
----- ----- --- -----
212 42 5 C:\main.c
235 0 0 C:\Program Files\PICC\devices\16F876.h
115 0 0 C:\Alertus_Globals.h
243 74 8 U:\PIC\myDrivers\LCD420_portb_except_enable.c
170 18 2 C:\rdsGroup.c
185 0 0 C:\RTMessageProtocol.c
71 10 1 U:\PIC\myDrivers\BitArray.c
200 0 0 C:\I2C_EEPROM.c
121 0 0 C:\adc.c
287 59 6 C:\SAA6588.c
659 141 13 C:\TEA5768HL.c
164 0 0 U:\PIC\myDrivers\TerminalHelper.c
28 0 0 C:\Program Files\PICC\drivers\ctype.h
749 317 26 C:\Program Files\PICC\drivers\stdlib.h
28 0 0 C:\Program Files\PICC\drivers\stddef.h
423 127 8 C:\Program Files\PICC\drivers\string.h
87 11 1 C:\alarm.c
60 8 0 C:\battery.c
152 45 3 C:\alertuslcd.c
166 36 2 C:\interupts.c
----- -----
8710 1776 Total
Page ROM % RAM Functions:
---- --- --- --- ----------
0 21 1 1 @delay_ms1
0 18 1 1 @I2C_WRITEU_1_59_60
0 15 1 1 @I2C_READU_1_59_60
0 8 0 0 @const57
0 24 1 1 lcd_send_nibble
0 96 4 3 lcd_send_byte
0 65 2 2 lcd_init
0 50 2 3 lcd_gotoxy
0 58 2 1 lcd_putc
0 11 0 0 lcd_clear
0 13 0 0 initSerialEEPROM
0 331 13 1 processRDSGroupBuffer
0 36 1 1 isSAA6588Ready
0 120 5 0 initRDSChip
0 217 8 9 writeRadioSettings
0 102 4 0 readRadioSettings
0 12 0 1 getRadioADC
0 60 2 6 getCurrStationFreq
0 41 2 8 setStationWithHighSideInjection
0 10 0 1 setSWPort2
0 24 1 0 @const12011
0 14 1 0 @const12019
0 14 1 0 @const12026
0 7 0 0 stopCharging
0 9 0 0 stopwatch_isr
0 31 1 0 lcdPaging_isr
0 24 1 1 isr_timer2
0 11 0 0 @const12327
0 212 8 11 EXT_isr
1 814 31 12 main
0 13 0 0 @const12369
0 24 1 0 @const12374
0 26 1 0 @const12379
0 13 0 0 @const12384
0 10 0 0 @const12389
0 14 1 0 @const12394
Segment Used Free
--------- ---- ----
00000-00003 4 0
00004-0004B 72 0
0004C-007FF 1754 218
00800-00FFF 814 1234
01000-017FF 0 2048
01800-01FFF 0 2048 _________________ "Everything should be made as simple as possible, but not one bit simpler" -- Albert Einstein
http://www.blakerobertson.com |
|
|
Mark
Joined: 07 Sep 2003 Posts: 2838 Location: Atlanta, GA
|
|
Posted: Mon Oct 04, 2004 3:36 am |
|
|
Post the first part of the program up to your main().
If you are using the ICD to "run" then you might have problems. |
|
|
blak3r
Joined: 11 Jan 2004 Posts: 45
|
|
Posted: Mon Oct 04, 2004 1:43 pm |
|
|
#include <16F876.h>
//#device ICD=TRUE
#device ADC=10 *=16
#use delay(clock=3580000)
#fuses NOWDT,XT, PUT, NOPROTECT, NOBROWNOUT, NOLVP, NOCPD, NOWRT, NODEBUG
#opt 9
//-=-=-=-=-=-=-==-[ Include Files aka Driver Files ]-=-=-=-=-=-=-=-=-=-=-//
#use i2c(Master,Slow,sda=PIN_C4,scl=PIN_C3,force_hw)
#use rs232(baud=38400, xmit=PIN_C6, rcv=PIN_C7, ERRORS)//changed
#include "./Alertus_Globals.h" // contains most of the defines and global variables of the programs
#include <LCD420_portb_except_enable.c> // lcd driver file for lcd being on port b except the enable pin
// *************** INTERRUPTS ARE IN Interupts.c ************************** //
#include "interupts.c" // <-- include file which contains interupt routines
main()
{
// ---------------[ Local Variables ]--------------------------------------//
int i, ctr;
int initStateIteration = -1;
long theStation;
//-=-=-=-=-=-=-=-=[ Setup PIC Hardware ]=-=-=-=-=-=-=-=-=-=-=-=-=-//
setup_adc_ports(RA0_RA1_RA3_ANALOG); // sets pins A0, A1 & A3 to analog inputs
setup_adc(ADC_CLOCK_INTERNAL);
setup_counters(RTCC_INTERNAL,RTCC_DIV_256);
setup_timer_1(T1_INTERNAL|T1_DIV_BY_8);
setup_timer_2(T2_DIV_BY_16,255,16); // creates a freq
setup_ccp2(CCP_OFF); // sets PWM frequency for the backlight of the LCD
setup_ccp1(CCP_OFF); // sets PWM frequency for the piezo speaker. Disable until called.
ext_int_edge( H_TO_L );
disable_interrupts(global);
//-----[ Initialization ]-----------------------------------------//
delay_ms(50);
lcd_init(); // initializes LCD
initSerialEEPROM(); // initializes i2c eeprom
initRadio(); // initializes Radio Chip
initRdsChip(); // initializes RDS Chip
stopCharging(); // makes sure battery charge i/o pin is initially low.
// todo: make internal/external antenna selection intelligent
setSWPort1(0);
theStation = 939;
setStationAndAntenna( theStation );
// Initial State
_state = STATE_WAITING;
printf("Starting");
// Prints an initial program screen with program info
firmwareVersionPage(); _________________ "Everything should be made as simple as possible, but not one bit simpler" -- Albert Einstein
http://www.blakerobertson.com |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Mon Oct 04, 2004 2:08 pm |
|
|
Quote: | My VDD w/o the ICD is 4.75V and my voltage w/ is 4.61 |
I would fix this before anything else. I assume your circuit is supposed
to be running at a nominal 5v. What if your LCD is spec'ed at +/- 5%
for Vdd ? Then you're either right at the lower bound, or you've
violated spec (based on the two voltages given above).
I would look at the LCD's data sheet to verify the proper operating
range for its Vdd.
I would get a better bench power supply, with more current.
Or, if your power supply has a knob which controls the amount
of current, then set it to the maximum position. |
|
|
|