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

Oscillator issue?

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



Joined: 07 Feb 2008
Posts: 167

View user's profile Send private message

Oscillator issue?
PostPosted: Fri Mar 08, 2024 9:15 am     Reply with quote

Hello Group:

I have an issue with a target using a PIC18F1220. Using CCS IDE v5.093 with ICD-U80 debugger.

Debugger works well with one prototype target, but this particular taget will not debug. When loading code, debugger responds with "Target program not running".

I have used CCS Load to manipulate MCLR (all okay), correct voltage shows up, but oscillator fails internal 8MHz.

Guess I could have a bad PIC?

Anyone see anything wrong with the simple code attached, particularly in osc selection?

Thanks for more good eyes.

Code:

#include <18F1220.h>
#include <ElecChoke (Rev A).h>

void Get_Pots(void);
void Set_Limits(void);

//=============================================================================

//=============================================================================
//Get all pots
void Get_Pots(void)
{
set_adc_channel(0);                    //get pedal input
Choke_Pos= read_adc();                   // Read from AN10 and store in BS
delay_ms(1);     
   

set_adc_channel(2);                    //get Low Speed input
Max_Ret_Pos= read_adc();                 
delay_ms(1);

set_adc_channel(3);                    //get Accel input
Max_Ext_Pos= read_adc();                   
delay_ms(1);
}
//=============================================================================
//=============================================================================
void Set_Limits(void)
{
if (Choke_Pos <= 184)                        //force bounds of servo
   Choke_Pos = 184;
if (Choke_Pos >= 925)
   Choke_Pos = 925;


}
//=============================================================================
//=============================================================================
main()
{
// Setup the ECCP for PWM in half bridge mode.
setup_ccp1(CCP_PWM);

// setup timer 2 for 25kHz
setup_timer_2(T2_DIV_BY_16, 1000, 1);
setup_adc_ports(sAN0 | sAN1 | sAN2 | sAN3, VSS_VDD);
setup_adc(ADC_CLOCK_DIV_8);    // A/D clock/8 @8MHz,Tad=1uS

output_high (Servo_PWR);                             
                                       
while(1)
   {
   Get_Pots();
   Set_Limits();
   set_pwm1_duty(Choke_Pos);
   } 
}

Code:


#device ADC = 10

#fuses NOWDT, BROWNOUT, PUT, NOLVP
#USE delay(internal=8mhz)

#define Servo_PWR PIN_B4


int16 Max_Ext_Pos;
int16 Max_Ret_Pos;
int16 Choke_Pos;
int16 Accel;
int16 Pedal;
Ttelmah



Joined: 11 Mar 2010
Posts: 19529

View user's profile Send private message

PostPosted: Fri Mar 08, 2024 10:03 am     Reply with quote

I the OSC2 pin is available to you, enable the clock out, and probe this
pin with an oscilloscope.
The oscillator can be unreliable if the supply is not well decoupled, but
I must admit the most likely cause is the chip itself.
JerryR



Joined: 07 Feb 2008
Posts: 167

View user's profile Send private message

PostPosted: Fri Mar 08, 2024 10:27 am     Reply with quote

Yes, I'll try to see if anything appears on OSC2, good suggestion.

Power supply should be well decoupled with 0.1uF and 10uF at the PICs pin.

Thanks!
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