View previous topic :: View next topic |
Author |
Message |
CombatWombat Guest
|
Spot the error (should be easy) |
Posted: Fri Sep 12, 2008 6:49 pm |
|
|
Hello,
I am trying to compile a very (very) simple program to learn the C (PCM V4) compiler. I know a bit of assembly using MPLAB already.
I am using a PIC16F690 on the Pickit2 low pin count demo board and using a Pickit2 for programming.
When I flash the chip with a program written in assembly, it works as expected (lights are flashing).
When I compile and flash the following program, my light stays on solid.
Code: | #include "D:\Projects\PIC\test2\test2.h"
void main()
{
setup_adc_ports(NO_ANALOGS|VSS_VDD);
setup_adc(ADC_OFF);
setup_spi(FALSE);
setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);
setup_timer_1(T1_DISABLED);
setup_timer_2(T2_DISABLED,0,1);
setup_oscillator(False);
set_tris_c(0x00);
while(1)
{
output_high(PIN_C0);
delay_ms(1000);
output_low(PIN_C0);
delay_ms(1000);
}
} |
The header (compiler generated) looks like so,
Code: | #include <16F690.h>
#device adc=8
#FUSES NOWDT //No Watch Dog Timer
#FUSES INTRC //Internal RC Osc
#FUSES NOPROTECT //Code not protected from reading
#FUSES NOBROWNOUT //No brownout reset
#FUSES NOMCLR //Master Clear pin used for I/O
#FUSES NOCPD //No EE protection
#FUSES NOPUT //No Power Up Timer
#FUSES IESO //Internal External Switch Over mode enabled
#FUSES FCMEN //Fail-safe clock monitor enabled
#use delay(clock=20000000)
#use rs232(baud=9600,parity=N,xmit=PIN_C6,rcv=PIN_C7,bits=8) |
I thought maybe the WDT or brownout was tripping, so I turned those off. Once programmed the LED on port C0 turns on and stays on.
Ideas? Im running out. Are there instructions for loading a C program into MPLAB to use the simulator? I have not found them.
Thank you. |
|
![](templates/subSilver/images/spacer.gif) |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
![](templates/subSilver/images/spacer.gif) |
jfarkas
Joined: 07 Dec 2006 Posts: 4 Location: Croatia
|
Datasheet |
Posted: Sat Sep 13, 2008 3:52 am |
|
|
This could be problem....
#FUSES INTRC //Internal RC Osc
#use delay(clock=20000000) ??????????? |
|
![](templates/subSilver/images/spacer.gif) |
Gerhard
Joined: 30 Aug 2007 Posts: 144 Location: South Africa
|
|
Posted: Sat Sep 13, 2008 8:26 am |
|
|
The internal oscilator on that pic is running at 4M. Just change that line
Code: | #FUSES INTRC //Internal RC Osc
#use delay(clock=20000000) |
To
Code: | #FUSES INTRC //Internal RC Osc
#use delay(clock=4M) |
|
|
![](templates/subSilver/images/spacer.gif) |
|