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

PIC24FJ128GA006 resting!!!!

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



Joined: 05 Feb 2009
Posts: 6

View user's profile Send private message

PIC24FJ128GA006 resting!!!!
PostPosted: Thu Feb 05, 2009 10:14 am     Reply with quote

Hi Guys
I'm new with the CCS compiler just downloaded the demo.

I have written this little demo prog for the PIC24.
When I run it keeps resetting. The other compiler I have it works fine?
See code below.

I have a feeling it could be the fuse setting but cant see where.

Can anyone help please.

Code:
#include <24FJ128GA006.h>

#FUSES NOWDT                    //No Watch Dog Timer
#FUSES NOJTAG                   //JTAG disabled
#FUSES NOPROTECT                //Code not protected from reading
#FUSES NOWRT                    //Program memory not write protected
#FUSES NODEBUG                  //No Debug mode for ICD
#FUSES NOCOE                    //Device will reset into operational mode
#FUSES ICS0                     //ICD communication channel 0
#FUSES NOWINDIS                 //Watch Dog Timer in Window mode
#FUSES WPRES32                  //Watch Dog Timer PreScalar 1:32
#FUSES WPOSTS1                  //Watch Dog Timer PostScalar 1:1
#FUSES NOIESO                   //Internal External Switch Over mode disabled
#FUSES FRC                      //Internal Fast RC Oscillator
#FUSES NOCKSFSM                 //Clock Switching is disabled, fail Safe clock monitor is disabled
#FUSES NOOSCIO                  //OSC2 is general purpose output
#FUSES NOPR                     //Pimary oscillaotr disabled

#use delay(clock=16000000)


main code:
Code:

#include "E:\proteus\scope\main.h"

unsigned int sample;
unsigned char adc_1_data[1024];

void main()
{
   setup_spi(SPI_SS_DISABLED);
   setup_spi2(SPI_SS_DISABLED);


   setup_wdt(WDT_OFF);
   setup_timer1(TMR_DISABLED);



   // TODO: USER CODE!!
   
     
     do
     {
           if(sample==1024)
           {
               sample=0;
           }
           else
           {
               adc_1_data[sample]=input_d();
               output_d(adc_1_data[sample]);
               ++sample;
           }
    }
    while(1);
}
kev_korea



Joined: 05 Feb 2009
Posts: 6

View user's profile Send private message

PostPosted: Thu Feb 05, 2009 10:22 am     Reply with quote

Sorry the variables shold have read
Code:

unsigned long sample;
unsigned char adc_1_data[1024];

Forgot to add it keeps resetting @ address 0x200.
asmallri



Joined: 12 Aug 2004
Posts: 1634
Location: Perth, Australia

View user's profile Send private message Send e-mail Visit poster's website

PostPosted: Thu Feb 05, 2009 1:14 pm     Reply with quote

you never initialized sample so it can attempting to access an array element outside the legal address range.
_________________
Regards, Andrew

http://www.brushelectronics.com/software
Home of Ethernet, SD card and Encrypted Serial Bootloaders for PICs!!
kev_korea



Joined: 05 Feb 2009
Posts: 6

View user's profile Send private message

PostPosted: Thu Feb 05, 2009 6:53 pm     Reply with quote

HI asmallri
I tried that but it is still generating the two SETM 32C and SETM 32A instructions. Its the second instruction that causes the reset.
I have tried changing all the fuses but still the same.
Code:

.................... 
....................     unsigned int sample =0;
*
0020C:  CLR     800
....................     unsigned char adc_1_data[1024];
.................... 
.................... 
.................... void main()
.................... {
*
00200:  SETM    32C
00202:  SETM    32A
00204:  MOV     #2780,W15
00206:  MOV     #27FF,W0
00208:  MOV     W0,20
0020A:  NOP
FvM



Joined: 27 Aug 2008
Posts: 2337
Location: Germany

View user's profile Send private message

PostPosted: Fri Feb 06, 2009 12:51 am     Reply with quote

How do you check, that setm 32A causes a reset?

However, it's a non-existing SFR address with 24FJ128GA006. Accessing it possibly may cause an address trap. (I don't have the chip, so I can't try). In this case, a dummy trap handler would be a workaround to this PCD bug.

Code:
#INT_ADDRERR
   void  ae_isr(void)
{
}
kev_korea



Joined: 05 Feb 2009
Posts: 6

View user's profile Send private message

PostPosted: Fri Feb 06, 2009 3:01 am     Reply with quote

I was starting to think the same it was probably a bug in PCD.
I tried generating a project with the standard fuse setting using the 24 bit wizard did the same thing.
I was using proteus to simulate the software, it did say it was a write to an illegal address
Thanks
asmallri



Joined: 12 Aug 2004
Posts: 1634
Location: Perth, Australia

View user's profile Send private message Send e-mail Visit poster's website

PostPosted: Fri Feb 06, 2009 9:04 am     Reply with quote

kev_korea wrote:
I was starting to think the same it was probably a bug in PCD.
I tried generating a project with the standard fuse setting using the 24 bit wizard did the same thing.
I was using proteus to simulate the software, it did say it was a write to an illegal address
Thanks


I gave up on PCD. I spent a week trying to port a working application from C30 to PCD on the same target. The PIC would reset at a certain point. If I added code in a completely unrelated area then it would reset at some other unrelated area of code.
_________________
Regards, Andrew

http://www.brushelectronics.com/software
Home of Ethernet, SD card and Encrypted Serial Bootloaders for PICs!!
Guest








PostPosted: Fri Feb 06, 2009 9:38 am     Reply with quote

try opening up the array to 1025,
kev_korea



Joined: 05 Feb 2009
Posts: 6

View user's profile Send private message

PostPosted: Fri Feb 06, 2009 10:25 am     Reply with quote

Thanks for the suggestion.

The problem is before the array is defined, if you look at the assembler output you can see that the 2 SETM instructions are at the start of "main" the very first instructions executed after the goto from power on reset.

I have generated another file with no code other that what was put in the .c file and .h file by the project wizard. Guess what it does exactly the same thing, I have played around with the fuses with no sucess.

I'm at a loss what to do next. Wanted to use CCS because it can be used with MPLAB and outputs COF files. BUT looks like I'm going to have to try else where.
But I'm still hoping
FvM



Joined: 27 Aug 2008
Posts: 2337
Location: Germany

View user's profile Send private message

PostPosted: Fri Feb 06, 2009 12:56 pm     Reply with quote

PCD is working to a certain extent. As previously reported, I was able to finish a complex (>10k lines of code) application some months ago. If you aren't able to identify the bugs at the assembly level and find workarounds, you may be lost. The velocity of PCD bug fixing seems to me rather leisurely, B.T.W.

In the present case, the problem hasn't anything to do with fuses, arrays or such. The said instruction is initializing ADC input pins to default digital (no analog) setting, unfortunately, xxGA006 has less pins and don't need a AD1PCFGH register that is present with other chips. The code was apparently intended to fit all, but it doesn't. You may either want to check the workaround or continue trying unrelated means.
kev_korea



Joined: 05 Feb 2009
Posts: 6

View user's profile Send private message

PostPosted: Fri Feb 06, 2009 7:46 pm     Reply with quote

FVM thanks for your reply.

I'm not quite sure what to do in the int routine as a work around.

Does anyone have an idea ? !!!!!
FvM



Joined: 27 Aug 2008
Posts: 2337
Location: Germany

View user's profile Send private message

PostPosted: Sat Feb 07, 2009 2:27 am     Reply with quote

You've to do nothing in the routine. It's purpose is in keeping an unhandled address error trap from resetting the processor. Read PIC24 family reference manual about address error trap and trap conflict reset for clarification.
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