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

Picdem2 board, ICD2, 18F1220, USB, MPLAB 6.21 not programmin

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







Picdem2 board, ICD2, 18F1220, USB, MPLAB 6.21 not programmin
PostPosted: Thu May 22, 2003 10:29 am     Reply with quote

<font face="Courier New" size=-1>I have used the CCS wizard for a project targeted to an 18f1220. I had to change the pwm output pin setup by the wizard to match the chips datasheet.
The chip appears to program/debugg correctly, and steps through the program. However, I am unable to get a simple toggle LED program to work. I am testing pins on portb for the LED.
Another curriosity is that the RB0 LED on the development board is dimly lit.
Using the simulator I see that the code is only setting RB1 as an output. CCP1 should be on RB3.
Nothing that I have read so far leads me to a solution. Any ideas?

#include "C:\piccode\18fDash\18fDash.h"
#int_RB
RB_isr() { //(used later for an encoder)
}
void main() {

//port_b_pullups(TRUE);
setup_adc_ports(ANALOG_AN0);
setup_adc(ADC_CLOCK_INTERNAL);
setup_wdt(WDT_OFF);
setup_timer_0(RTCC_INTERNAL);
setup_timer_1(T1_DISABLED);
setup_timer_2(T2_DIV_BY_1,199,1);
setup_timer_3(T3_DISABLED|T3_DIV_BY_1);
setup_ccp1(CCP_PWM);
enable_interrupts(INT_RB);
enable_interrupts(global);
while(1){set_pwm1_duty(50);}
}
</font>
___________________________
This message was ported from CCS's old forum
Original Post ID: 144514677
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

Re: Picdem2 board, ICD2, 18F1220, USB, MPLAB 6.21 not progra
PostPosted: Thu May 22, 2003 1:30 pm     Reply with quote

<font face="Courier New" size=-1>:=I have used the CCS wizard for a project targeted to an 18f1220. I had to change the pwm output pin setup by the wizard to match the chips datasheet.

You should compare the settings in the Device Editor for
the 18F1220 to the data sheet. Make sure they're correct.

:=The chip appears to program/debug correctly, and steps through the program. However, I am unable to get a simple toggle LED program to work. I am testing pins on portb for the LED.

This chip supports Low Voltage Programming, with pin RB5 being
used as the PGM pin. Since the ICD uses high voltage
programming, you need to disable LVP by adding NOLVP to the
end of your #fuses statement. Doing so may fix a lot of your
problems.

:=Another curiosity is that the RB0 LED on the development board is dimly lit.
:=Using the simulator I see that the code is only setting RB1 as an output. CCP1 should be on RB3.

Check the Device Editor settings. Change them if required.

:=Nothing that I have read so far leads me to a solution. Any ideas?

This code below, is way too complicated for the purpose of
testing a new chip. You should strip it down to practically
nothing. Example:

<PRE>
#include <18F1220.h>
#fuses ..... , NOLVP // Add your fuses. NOLVP is essential.
#use delay(clock = 4000000) // Or whatever clock you're using.

void main(void)
{

// This loop will toggle an LED on/off, on pin B0. Be sure the
// LED has a series resistor -- 220 to 330 ohms should work.
while(1)
{
output_low(PIN_B0);
delay_ms(500);
output_high(PIN_B0);
delay_ms(500);
}

}
</PRE>

:=
:=#include "C:\piccode\18fDash\18fDash.h"
:=#int_RB
:=RB_isr() { //(used later for an encoder)
:=}
:=void main() {
:=
:= //port_b_pullups(TRUE);
:= setup_adc_ports(ANALOG_AN0);
:= setup_adc(ADC_CLOCK_INTERNAL);
:= setup_wdt(WDT_OFF);
:= setup_timer_0(RTCC_INTERNAL);
:= setup_timer_1(T1_DISABLED);
:= setup_timer_2(T2_DIV_BY_1,199,1);
:= setup_timer_3(T3_DISABLED|T3_DIV_BY_1);
:= setup_ccp1(CCP_PWM);
:= enable_interrupts(INT_RB);
:= enable_interrupts(global);
:= while(1){set_pwm1_duty(50);}
:=}
:=




--</font>
___________________________
This message was ported from CCS's old forum
Original Post ID: 144514681
mcbrideja
Guest







Re: Picdem2 board, ICD2, 18F1220, USB, MPLAB 6.21 not progra
PostPosted: Thu May 22, 2003 11:01 pm     Reply with quote

:=This chip supports Low Voltage Programming, with pin RB5 being
:=used as the PGM pin. Since the ICD uses high voltage
:=programming, you need to disable LVP by adding NOLVP to the
:=end of your #fuses statement. Doing so may fix a lot of your
:=problems.

My header file (not shown) got rid of LVP WDT and a few others. I have been bit by this in the past.

:=Check the Device Editor settings. Change them if required.

Ok, will do. Should I make CCS aware of faults?

:=This code below, is way too complicated for the purpose of
:=testing a new chip. You should strip it down to practically
:=nothing.
Yep, your right. In my defence however, it is practically the simplest program that the wizard would generate. I guess it is time to leave the nest and the wizard behind.

:=// This loop will toggle an LED on/off, on pin B0. Be sure the
:=// LED has a series resistor -- 220 to 330 ohms should work.

This code is exactly what I did with my wizard program add-ons.
But it seemed like a good idea to get rid of the fluff. And it was comforting to know that you said it would work. And guess what? It works.... well sort of. It does toggle on and off an LED buildt into the PICDEM2 demo board. Only problem is, the program is toggling RB2! Well time to do some homework. I just "assumed" the compiler would get it all right. It will help me learn the ins and outs of the 18f1220 anyway.

Thanks much!!
___________________________
This message was ported from CCS's old forum
Original Post ID: 144514689
R.J.Hamlett
Guest







Re: Picdem2 board, ICD2, 18F1220, USB, MPLAB 6.21 not progra
PostPosted: Fri May 23, 2003 5:45 am     Reply with quote

:=<font face="Courier New" size=-1>I have used the CCS wizard for a project targeted to an 18f1220. I had to change the pwm output pin setup by the wizard to match the chips datasheet.
:=The chip appears to program/debugg correctly, and steps through the program. However, I am unable to get a simple toggle LED program to work. I am testing pins on portb for the LED.
:=Another curriosity is that the RB0 LED on the development board is dimly lit.
One thought here. You have 'week pull ups' enabled. In some cases these can draw as much as 400uA, and this is enough to light an LED connected to such a pin.

:=Using the simulator I see that the code is only setting RB1 as an output. CCP1 should be on RB3.
:=Nothing that I have read so far leads me to a solution. Any ideas?
:=
:=#include "C:\piccode\18fDash\18fDash.h"
:=#int_RB
:=RB_isr() { //(used later for an encoder)
:=}
:=void main() {
:=
:= //port_b_pullups(TRUE);
:= setup_adc_ports(ANALOG_AN0);
:= setup_adc(ADC_CLOCK_INTERNAL);
:= setup_wdt(WDT_OFF);
:= setup_timer_0(RTCC_INTERNAL);
:= setup_timer_1(T1_DISABLED);
:= setup_timer_2(T2_DIV_BY_1,199,1);
:= setup_timer_3(T3_DISABLED|T3_DIV_BY_1);
:= setup_ccp1(CCP_PWM);
:= enable_interrupts(INT_RB);
:= enable_interrupts(global);
:= while(1){set_pwm1_duty(50);}
:=}
:=</font>

Best Wishes
___________________________
This message was ported from CCS's old forum
Original Post ID: 144514697
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