CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

PIC 18F4620 bug?

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Georg Prinz



Joined: 07 Jan 2004
Posts: 22
Location: Frankfurt, Germany

View user's profile Send private message Send e-mail

PIC 18F4620 bug?
PostPosted: Sun Oct 02, 2005 8:02 am     Reply with quote

Hi folks,
I started a new project with 18f4620 facing severe problem. The first chip I couldn't set the fuses. Replacing the chip by a new one, every thing seemd to be ok, the code was loaded, but nothing happened. Setting debug halts, showed that the interrupt was firing, but counter1 stucked to random value. Only the "if"-code line worked, nothing else.
I'am using PCH version 3.213 and ICD V2.12 (CCS 1.33 Rev. #97 for pic16 & pic18).

Test-Program
Code:

#include "C:\Programme\PICC\Devices\18F4620.h"

#device icd=true              // Debug flag


#FUSES HS                     // Crystal osc highmhz
#FUSES NOWDT                  // No Watch Dog Timer
#FUSES NOLVP                  // No low voltage programing
#FUSES NOPROTECT              // Code not protected from reading
#FUSES NOBROWNOUT             // no Reset when brownout detected
#FUSES DEBUG                  // Test code to be generated
#FUSES MCLR                   // Master clear pin enabled
#FUSES NOCPD                  // No EE protection

#use delay(clock=20000000)    // 20 MHz quartz

#use fast_io(c)
#use fast_io(d)

static long counter1, R;

#define Red   PIN_D2
#define Green PIN_C4
#define White PIN_C2

#define Red_blink   10


//------------------------------------------------------------------------------

#int_RTCC
RTCC_isr()
  {
   counter1 = counter1 - 1;
   if(!counter1)
     {
      counter1 = Red_blink;
      output_toggle(Red);

     }
  }

//------------------------------------------------------------------------------

void main()
{
 setup_timer_0(RTCC_INTERNAL | RTCC_DIV_256);
 counter1 = Red_blink;
 R = Red_blink;
 enable_interrupts(INT_RTCC);
 enable_interrupts(GLOBAL);

 do
 {

   R = R - 1;
   If(!R) R = Red_blink;
   delay_ms(500);
 } while(1);


}

 :evil:
Any idea?

Gracias for help in andvance

Georg

_________________
dl 2 kp
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sun Oct 02, 2005 11:19 am     Reply with quote

One problem is that you're using #fast_io but you never set the TRIS.

My suggestion is to comment out those lines.
// #use fast_io(c)
// #use fast_io(d)

Then the compiler will automatically set the TRIS when you use
the CCS pin functions:

output_low()
output_high()
output_toggle()
etc.
Georg Prinz



Joined: 07 Jan 2004
Posts: 22
Location: Frankfurt, Germany

View user's profile Send private message Send e-mail

PostPosted: Sun Oct 02, 2005 1:28 pm     Reply with quote

Thanks for replying so fast,

but I'am very sorry these lines are left from playing around. I already commented them out without any result. In the main routine the counter is not set to the start value and in the loop as well in the interrupt service routine the counter is not decremented. It is crazy.

Georg
_________________
dl 2 kp
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sun Oct 02, 2005 2:28 pm     Reply with quote

Quote:
In the main routine the counter is not set to the start value

Do you mean that in the code shown below, counter1 is not set equal to 10 ?
Code:
#define Red_blink   10

void main()
{
 setup_timer_0(RTCC_INTERNAL | RTCC_DIV_256);
 counter1 = Red_blink;
 R = Red_blink;


I assume you are checking this with the CCS debugger. What happens
if you use a printf statement ? What does it display ? Example:
Code:

counter1 = Red_blink;
printf("counter1 = %LX \n\r", counter1);


Quote:
I'am very sorry these lines are left from playing around. I already commented them out without any result.

Is the rest of the posted program accurate ? I can't really help you
unless I see the exact code that you're running.

---------------------

1. If you're having weird problems, then check the "Limitations" section
for ICD2 help in MPLAB. I know you're using CCS ICD and PCWH
IDE, but some of the same limitations will still apply.
Quote:
PIC18FXX20/XX31 Limitations:
You must connect the AVDD and AVSS pins for the device to program.
(ie., connect them to Vdd and Ground -- don't leave them unconnected).

2. Also, I wonder if the Config bits are being set correctly ?
Look near the end of your .LST file, and find the section called "Configuration Fuses" and post it.
Georg Prinz



Joined: 07 Jan 2004
Posts: 22
Location: Frankfurt, Germany

View user's profile Send private message Send e-mail

Running!!
PostPosted: Mon Oct 03, 2005 8:48 am     Reply with quote

Very Happy I made him legs to run!

Hallo PCM Programmer,

thanks for your suggestions! After going through of all your proposals and digging in Microchips documentation I remembered reading somewhere, maybe even on this forum, that some chips shall be operated first with a lower frequency oscilator. Therefore I change the quartz to 4MHz and "Heureka!" it's running. Then I went to 10MHZ and last back to 20MHz. Not only both frequencies are working even the first chip, which I couldn't even set the fuses is running now.

Now I'am happy, but on the other side it is frustrating loosing lot of time.
Do you have a explanation about this weird behavior. I did'nt change anything in the program, except I set "NOPUT fuses", but this config bit was disabled before as standard, when no fuse-command was included.

Best Regards,
I appreciate this forum very much. I remember former times very well, sitting long nights struggling software problems without any help and any internet.

Gerog
_________________
dl 2 kp
Georg Prinz



Joined: 07 Jan 2004
Posts: 22
Location: Frankfurt, Germany

View user's profile Send private message Send e-mail

Running!!
PostPosted: Mon Oct 03, 2005 8:48 am     Reply with quote

Very Happy I made him legs to run!

Hallo PCM Programmer,

thanks for your suggestions! After going through of all your proposals and digging in Microchips documentation I remembered reading somewhere, maybe even on this forum, that some chips shall be operated first with a lower frequency oscilator. Therefore I change the quartz to 4MHz and "Heureka!" it's running. Then I went to 10MHZ and last back to 20MHz. Not only both frequencies are working even the first chip, which I couldn't even set the fuses is running now.

Now I'am happy, but on the other side it is frustrating loosing lot of time.
Do you have a explanation about this weird behavior. I did'nt change anything in the program, except I set "NOPUT fuses", but this config bit was disabled before as standard, when no fuse-command was included.

Best Regards,
I appreciate this forum very much. I remember former times very well, sitting long nights struggling software problems without any help and any internet.

Gerog
_________________
dl 2 kp
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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