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 CCS Technical Support

Why is THIS important??

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



Joined: 09 Jun 2013
Posts: 153

View user's profile Send private message Visit poster's website

Why is THIS important??
PostPosted: Sun Jun 23, 2013 1:32 pm     Reply with quote

Ok, i am ripping out my hair because no matter what CCS says, the data sheet doesn't match up.

I've used this chip successfully before, on CCS 4.114

SAME code, 4.130 it works yet the system keeps rebooting or restarting as though Watch dog is in use!

CCS 4.114, it works FINE, ONLY when i have a call to reset_cpu() in a FUNCTION that is NEVER used! or setup as interrupted!??

Code:

#include "24HJ128GP502.h"
#device *=16
#device WRITE_EEPROM = NOINT

#FUSES WPRES32                  //Watch Dog Timer PreScalar 1:32
#FUSES WPOSTS1                  //Watch Dog Timer PostScalar 1:1
#FUSES PROTECT_HIGH             //General Segment Code Protect High Security
#FUSES CKSFSM                   //Clock Switching is enabled, fail Safe clock monitor is enabled


#FUSES NOWDT                    //No Watch Dog Timer
#FUSES NOWRTB                   //Boot block not write protected
#FUSES NOBSS                    //No boot segment
#FUSES NORBS                    //No Boot RAM defined
#FUSES NOWRTSS                  //Secure segment not write protected
#FUSES NOSSS                    //No secure segment
#FUSES NORSS                    //No secure segment RAM
#FUSES NOWRT                    //Program memory not write protected
#FUSES NOPROTECT                //Code not protected from reading
#FUSES PR_PLL                   //Primary Oscillator with PLL
#FUSES FRC_PLL
//#FUSES NOPR                   //Primary Oscillator with PLL
#FUSES NOIESO                   //Internal External Switch Over mode disabled
//#FUSES NOPR                     //Pimary oscillaotr disabled
#FUSES OSCIO                    //OSC2 is general purpose output
#FUSES NOIOL1WAY                //Allows multiple reconfigurations of peripheral pins
#FUSES CKSFSM                 //Clock Switching is disabled, fail Safe clock monitor is disabled
#FUSES WPOSTS16                 //Watch Dog Timer PostScalar 1:32768
#FUSES WPRES128                 //Watch Dog Timer PreScalar 1:128
#FUSES WINDIS                 //Watch Dog Timer in Window mode
#FUSES PUT128                    //Power On Reset Timer value 64ms
#FUSES NOALTI2C                 //I2C mapped to alternate pins
#FUSES ICSP1                    //ICD uses PGC1/PGD1 pins
#FUSES NOJTAG                   //JTAG disabled
#FUSES NODEBUG                  //No Debug mode for ICD




#use delay(clock=64M, CRYSTAL=12M)


#pin_select U1TX       = PIN_B0
#pin_select   U2RX       = PIN_B1

#PIN_SELECT OC1       = PIN_B6      // AUDIO RIGHT , LEG 15.
#PIN_SELECT OC2      = PIN_B7      //   AUDIO LEFT, LEG 16

#pin_select   SS1OUT   = PIN_B15
#pin_select   SCK1OUT   = PIN_B14
#pin_select   SDI1      = PIN_B13
#pin_select SDO1      = PIN_B12


//#use rs232(UART1, baud=57600,parity=N,bits=8,stream=PORT1)
#use rs232(STREAM=UART1,baud=57600, parity=N,bits=8,ERRORS)



#DEFINE      RIGHT_PWM   0x01   
#DEFINE      LEFT_PWM      0x02



#use fast_io(b)

#ZERO_RAM

#bit SSPEN=getenv("BIT:SSPEN")

/* THESE ARE MY CHIP SPECIFICS */
#define MMC_CS    PIN_c2
#define MMC_CLK   PIN_c3
#define MMC_DI    PIN_C4
#define MMC_DO    PIN_C5


#define MMCSD_PIN_SELECT  MMC_CS //o
#define MMCSD_PIN_SCL     MMC_CLK //o
#define MMCSD_PIN_SDI     MMC_DI //i
#define MMCSD_PIN_SDO     MMC_DO //o


#use FAST_IO(C)

#include <string.h>


#define SOUNDBUFFERSIZE 1536
char       buffer[SOUNDBUFFERSIZE];

//char soundBuffer[SOUNDBUFFERSIZE];

int16    buffer_load;
int16    buffer_read_pos;
int16    buffer_write_pos;



//#include "modplay/modplayer.c"



//#int_timer3 HIGH   // wave form processor
void PlayBuffer(){
   
   if(buffer_write_pos != buffer_read_pos){
      //set_pwm2_duty((int16)buffer[buffer_read_pos]);
      set_pwm_duty(LEFT_PWM,       (int16)buffer[buffer_read_pos]);
      buffer_read_pos++;
      buffer_read_pos &= SOUNDBUFFERSIZE -1;
      if(buffer_load>0) buffer_load--;
     
     
   }
   if(input(PIN_B11)) reset_cpu(); //<---------- crazy times! this funtion is NOT called, yet its a matter of working or not! (CCS 4.114) although CCS 4.130- the chip just constantly reboots)
   clear_interrupt(int_timer3);
   
}

void main(){
   setup_wdt(WDT_OFF);
   //setup_timer1(TMR_INTERNAL | TMR_DIV_BY_8, 0x422F);      // used to get 750hz ADSR controllers  ///  80Mhz, on 6Mhz Crystal
   //setup_timer3(TMR_INTERNAL | TMR_DIV_BY_8, 0x012E);      // Wave Form Processing is mean for 22Khz Sampling.   ///  80Mhz, on 6Mhz Crystal


   setup_compare(RIGHT_PWM,    COMPARE_PWM | COMPARE_TIMER2 );         // configue output as PWMs
   setup_compare(LEFT_PWM,    COMPARE_PWM | COMPARE_TIMER2 );         // configue output as PWMs
   
   set_pwm_duty(RIGHT_PWM, 128);   
   set_pwm_duty(LEFT_PWM,    128);   
   
   
   set_tris_b(0b0000000000000000);
   
   
   delay_ms(10);
   
   fprintf(UART1, "Booted from PIC24HJ\r\n");
   
   // now UP THE CLOCK DRIVER for FULL on CPU usage! about 50MIPS (20% over clocked... seems safe here, any higher and risking RAM issues)                                                                 
   setup_oscillator( OSC_CRYSTAL , 64000000);
   
   for(;;){
      
      output_high(pin_b10);
      delay_ms(500);
      output_low(pin_b10);
      delay_ms(500);
   }
}
temtronic



Joined: 01 Jul 2010
Posts: 9243
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Sun Jun 23, 2013 2:05 pm     Reply with quote

I'd have to dump out the listings and compare the two.
It's not uncommon that a fuse(maybe WDT) is being set/reset to the wrong condition for a different compiler version which we can't tell by just the program.

hth
jay
Ttelmah



Joined: 11 Mar 2010
Posts: 19539

View user's profile Send private message

PostPosted: Sun Jun 23, 2013 2:07 pm     Reply with quote

You have not got a UART selected in your #use RS232. Surprised it compiles. The line above 'remmed' out, does have the UART selected, but lacks 'ERRORS'.
I'd suspect you were compiling with this line before.

Best Wishes
Mike Walne



Joined: 19 Feb 2004
Posts: 1785
Location: Boston Spa UK

View user's profile Send private message

PostPosted: Sun Jun 23, 2013 2:50 pm     Reply with quote

If it's re-booting, get the PIC to tell you what is causing the re-boot.

Attack the problem head on, don't flounder in the dark.

Mike
neochrome32



Joined: 09 Jun 2013
Posts: 153

View user's profile Send private message Visit poster's website

PostPosted: Sun Jun 23, 2013 6:50 pm     Reply with quote

the line

//#use rs232(UART1, baud=57600,parity=N,bits=8,stream=PORT1)
#use rs232(STREAM=UART1,baud=57600, parity=N,bits=8,ERRORS)

the one remmed out, didn't compile :( it was strange...

but why.. would a function that is NOT called, cause the chip to work??
neochrome32



Joined: 09 Jun 2013
Posts: 153

View user's profile Send private message Visit poster's website

PostPosted: Sun Jun 23, 2013 7:04 pm     Reply with quote

it just fixed it self! ok, now i AM confused!

the timing seems abit off though

12M crystal, and clock=48M

the seconds seem a few miliseconds off...
gpsmikey



Joined: 16 Nov 2010
Posts: 588
Location: Kirkland, WA

View user's profile Send private message

PostPosted: Sun Jun 23, 2013 7:16 pm     Reply with quote

A long shot, but I have run into things like that before where a function (or other "stuff") got compiled in, but was not called and changed the behavior because it moved things around in memory just by being there. I have seen that before.

mikey
_________________
mikey
-- you can't have too many gadgets or too much disk space !
old engineering saying: 1+1 = 3 for sufficiently large values of 1 or small values of 3
neochrome32



Joined: 09 Jun 2013
Posts: 153

View user's profile Send private message Visit poster's website

PostPosted: Mon Jun 24, 2013 2:08 am     Reply with quote

GPSMikey. It felt that way before, i've kept my old copy of CCS 4.114, compiled an old project,

then compile the same project in CCS 4.130, uploaded to chip..

then compile the code abolve in ccs 4.130 and things seem to work!??

I cant feel confident in CCS 4.130! as Fuses appears to be doing different things and/or there are more options of/else difference!

frustrated a bit though..

thanks everyone, dont normally ask for help i try to read up as much as possible first, but this one bugged me hells over!

---- thank you again folks ----
FvM



Joined: 27 Aug 2008
Posts: 2337
Location: Germany

View user's profile Send private message

PostPosted: Mon Jun 24, 2013 5:00 am     Reply with quote

I can't follow the problem report. Uncalled functions are removed during compilation, review the listing file.

Thus there are probably other reasons for reboot. Reboot with 16-Bit PICs should be always suspected
to be caused by a trap interrupt. Methods to catch it have been previously discussed in the forum.
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