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

24EP512GU810 and debug issues

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



Joined: 07 Sep 2003
Posts: 755
Location: Florida

View user's profile Send private message AIM Address

24EP512GU810 and debug issues
PostPosted: Thu Dec 20, 2012 7:58 am     Reply with quote

I'm experimenting with some chips prior to using them in a project
that needs fast 64 bit float logic.
I'm using a protoboard from ETT but it isn't the issue.
I'm using a CCS iCD-U64 and CCS built in debugger
The 24FJ 24Hj chips work both at run time and at debug time
What works
I have this 24EP512GU810 clocked at 140Mhz and all seems to work for the run time version.
What isn't working with the 24EP512GU810
With the CCS debugger....strangely it reports the oscillator won't start or that there is an issue with MCLR but it loads the code and the chip starts running just as if debug mode was ignored.
Now there are issues with the CCS debugger on the 24H ..not reporting the correct freq if it is above 48Mhz ( I was running at 100Mhz ) but apart from that the debugger was working.
Has anyone got the CCS debugger to work with a 24EP512GU810 chip.
I have tried dropping the freq to 8 mhz but the debugger still won't work
I have 1M resistor in parallel with osc
I have LEDS on A0 A1 and they flash at the correct freq.

Here is the complete code I used to test
4.138

Code:
#include <24EP512GU810.h>

/// the 24ep can be clocked at  a max of 140mhz

//// ETT board has a push switch make sure orange for debug is on ( near switch)
///  the ETT board uses pins26 and 27 for ICD
///  for the 24HJ these pins are ICD1
///  for the 24FJ these pins are ICD2
///  for the 24EP these pins are ICD1
///  for the 32MX these pins are ICD2
//
//for the 24Hj and the 24EP a 1M resistor in parallel with the oscillator is mandatory
// this resistor is in place on the ETT board so all devices will have this resistor
///#device ICD=1 ///// must be commented out for production

///// notes
//// Nov 11 2012 osc is showing 7.47 Mhz something with the fuses 24FJ is not working
///  Nov14 addded clock switch and works overclocked at  100Mhz and max clocked of 80Mhz
///  HJ uses ICD1 device must be on second line ICD-U64 reports clock as 48.76 Mhz
///                   this is probably the max it can measure
//// ETT board has a push switch make sure orange for debug is on ( near switch)
//  EP this code works compiled
// same code with ICD=1 uncommeted errors with the debugger
/// osc not working or MCLR issue

#fuses XT,PR_PLL,PLLWAIT,ICSP1,PUT128,IESO,  NOJTAG


#define PLL_N1 2
#define PLL_M 70
#define PLL_N2 2
#define PLL_XTAL 8

/// setup_pll(N1,M,N2) xtal 8Mhz is ((8/2)*70)/2=140Mhz

#use delay(clock=140Mhz) // have to let the compiler know we're running at 140MHz
                        // the switch t0 140 Mhzoccurs at the very top of main
                      // but the compiler needs this at compile time
                       
#use rs232(debugger)
 
////// busy low level code to get osc set up
///   since use delay(clock=140Mhz,osc=8Mhz) isn't working
//// on chips with the new osc set up
///  instead  use setup_pll(PLL_N1,PLL_M,PLL_N2);
//// called in main()
#word CLKDIV = getenv("sfr:CLKDIV")
#bit PLLPOST0 = CLKDIV.6
#bit PLLPOST1 = CLKDIV.7
#word PLLFBD = getenv("sfr:PLLFBD")

struct struct_MIDDIV_M
{
   int M;    //0-7       
   int unused1;  //8-15
 
};
struct struct_MIDDIV_M MIDDIV ;
#word MIDDIV=getenv("sfr:PLLFBD")
struct struct_DIV_N1andN2
{
   int N1:5;    //0-4     
   int1 unused1; // 5
   int N2:2;  //6-7
   int unused2;  //15
};
struct struct_DIV_N1andN2 DIV_N1andN2;
#word DIV_N1andN2=getenv("sfr:CLKDIV")

struct struct_OSCCON
{
   int1 oswen;    //0      // oscillator switch enable
   int1 lposcen;  //1      // secondary (LP) oscillator enable
   int1 unused1;  //2
   int1 cf;       //3      // clock fail detect bit
   int1 unused2;  //4
   int1 lock;     //5      // PLL lock status
   int1 unused3;  //6
   int1 clklock;  //7      // clock lock enable
   int nosc:3;    //8-10   // new oscillator selection
   int1 unused4;  //11
   int cosc:3;    //12-14  // current oscillator selection
   int1 unused5;  //15
};
struct struct_OSCCON OSCCON;
#word OSCCON = getenv("sfr:OSCCON")

#byte OSCCONL = OSCCON
#byte OSCCONH = OSCCON+1
//#byte OSCCONL = 0x0742
//#byte OSCCONH = 0x0743


void setup_pll(int8 N1,int8 M,int8 N2)
{
   // This function is required because the 24HJ cannot startup with a 8MHz xtal
   // from powerup (not reliably, anyway). Must start the PIC using the internal
   // RC oscillator, then switch over to the external xtal with PLL. This also
   // requires a very time sensitive unlock sequence to directly access the
   // necessary registers to perform this task. #asm taken directly from
   // a microchip app note.
   
   // 8MHz xtal -> PLLPRE divider (N1) -> multiplier -> VCO -> PLLPOST divider (N2) -> Fosc
   //                                          ^         |
   //                                          |------PLLDIV (M)
   
   // 8MHz / 2 = 4MHz x 40 = 160MHz / 2 = 80MHz
   //         N1         M             N2
   
   // M = 38 (40 - 2), N1 = 1 (3 - 2), N2 = 0 (2)
   // N1
   CLKDIV = N1-2; // PLLPRE
   
   // N2
   //11 = Output/8
   //10 = Reserved
   //01 = Output/4 (default)
   //00 = Output/2
   if (n2==2)
   {
   PLLPOST0 = 0;
   PLLPOST1 = 0;
   }
   if (n2==4)
   {
   PLLPOST0 = 1;
   PLLPOST1 = 0;
   }
   if (n2==8)
   {
   PLLPOST0 = 1;
   PLLPOST1 = 1;
   }
   
   // M
   PLLFBD = M-2;

   #asm
   MOV #0x03, w0
   MOV OSCCONH, w1
   MOV #0x78, w2
   MOV #0x9A, w3
   MOV.B w2, [w1]
   MOV.B w3, [w1]
   MOV.B w0, [w1]
   
   MOV #0x01, w0
   MOV OSCCONL, w1
   MOV #0x46, w2
   MOV #0x57, w3
   MOV.B w2, [w1]
   MOV.B w3, [w1]
   MOV.B w0, [w1]
   #endasm
 
 
   
   while(OSCCON.cosc != 3); // wait for switchover to occur
   
   while (!OSCCON.lock); // wait for PLL to lock
   

   
   OSCCON.clklock = 1;
 
 
}
////////////////////////////////// LCD set up ////////////////////////
#define LCD_RS_PIN      PIN_E1                                    ////
#define LCD_RW_PIN      PIN_E2                                    ////
#define LCD_ENABLE_PIN  PIN_E3                                    ////
#define LCD_DATA4       PIN_E4                                    ////
#define LCD_DATA5       PIN_E5                                    ////
#define LCD_DATA6       PIN_E6                                    ////
#define LCD_DATA7       PIN_E7                                    ////
#define LCD_EXTENDED_NEWLINE

#include <LCD.c> //// has delay_xx() embedded

//// LCD interface and cable is in 4 bit mode d4,d5,d6,d7 are E4,E5,E6,E7


void main()
{
int32 i=0;
int16 actual_mhz,xtal_mhz=PLL_XTAL;
float64 f1,f2,f3;
///// use 3.3v ICDU64 programmer
//// ETT demo PIC32 KIt board doesn't have telco pin 6 blue wire connected
///    dk modded the board so blue wire goes to B3
char cmd;
 
   setup_pll(PLL_N1,PLL_M,PLL_N2); /// setup_pll(N1,M,N2) xtal 8Mhz is ((8/2)*70)/2=140Mhz

   setup_spi( FALSE );
   setup_spi2( FALSE );



   setup_timer1(TMR_DISABLED|TMR_DIV_BY_1);
   lcd_init();
   printf(lcd_putc,"hello\n\r");
 
 printf("hello  oscon=%04lx\n\r",getenv("sfr:OSCCON"));
 printf("new osc=%u old osc=%u\n\r",OSCCON.nosc,OSCCON.cosc);
 printf("PLL locked in =%u\n\r",OSCCON.lock);
  printf("Clock lock enabled =%u\n\r",OSCCON.clklock);
 printf("N1 =%u N2=%u M=%u\n\r",DIV_N1andN2.N1,DIV_N1andN2.N2,MIDDIV.M);
 actual_mhz=xtal_mhz/(DIV_N1andN2.N1+2);
 actual_mhz*=(MIDDIV.M+2);
 actual_mhz/=(DIV_N1andN2.N2+2);
 printf("xtal=%uMhz PLL=%uMhz\n\r",xtal_mhz,actual_mhz);
 
 f3=0f;
 f1=1.23456789f;
 f2=0.23456789f;
 f3+=f1/f2;
 printf("f3=%15.14f\n\r",f3);
 f3=0f;
 for(i=0;i<1000;i++)
 {
 f3+=f1/f2;
 
 lcd_gotoxy(1,1);
 printf(lcd_putc,"i=%lu\n\r",i);
 lcd_gotoxy(1,2);
 printf(lcd_putc,"f3=%15.14f",f3);
 
 }
 
 printf("f3=%15.14f\n\r",f3);
 
 while(1)
 {

 
 delay_ms(200);
 output_toggle(PIN_A0);
 output_toggle(PIN_A1);
// output_toggle(PIN_A2);
// output_toggle(PIN_A3);

 }

}
bkamen



Joined: 07 Jan 2004
Posts: 1615
Location: Central Illinois, USA

View user's profile Send private message

PostPosted: Thu Dec 20, 2012 11:23 am     Reply with quote

Avoiding the crickets --

I haven't used that chip.. so can't say.

Sorry,

-Ben
_________________
Dazed and confused? I don't think so. Just "plain lost" will do. :D
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