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 support@ccsinfo.com

18F25J11 PCWHD 4.108

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



Joined: 10 Feb 2004
Posts: 205

View user's profile Send private message

18F25J11 PCWHD 4.108
PostPosted: Thu Nov 18, 2010 11:42 am     Reply with quote

I cannot get the 18F25J11 to run in the debugger. I can use ccsload to load a program and it runs. It is not running the correct speed. With a 20MHZ crystal, my timing in the following is way off, the led blinks but too fast and data is transmitting but the baud rate is cuckoo. Am I leaving something out? I did have to Edit the part in CCS and tell CCS the correct part ID number. They had 4DA0 and I changed it to 4DC0 as this is what the ICD was reading from the device. With the INTRC at 8Mhz, I can get the correct baud rate to see data but the delay_ms is ignored completely and the data runs out the port all the time.

This is all just a test program to get things going....

Code:

#include <18F25j11.h>
//#device ICD=TRUE
#device adc=10
#use delay(clock=20000000,RESTART_WDT)


#FUSES NOWDT                    //No Watch Dog Timer
#FUSES WDT128                   //Watch Dog Timer uses 1:128 Postscale
//#FUSES INTRC                       //High speed Osc (> 4mhz for PCM/PCH) (>10mhz for PCD)
#FUSES HS
#FUSES NODEBUG                  //No Debug mode for ICD
#FUSES NOXINST                  //Extended set extension and Indexed Addressing mode disabled (Legacy mode)
#FUSES STVREN                   //Stack full/underflow will cause reset
#FUSES NOPROTECT                //Code not protected from reading
#FUSES FCMEN                    //Fail-safe clock monitor enabled
#FUSES IESO                     //Internal External Switch Over mode enabled
#FUSES NOIOL1WAY                  //Allows only one reconfiguration of peripheral pins
#FUSES PRIMARY                  //Primary clock is system clock when scs=00
#FUSES NOWPCFG               
#FUSES WPBEG                 
#FUSES WPDIS                 
#FUSES NOCPUDIV             
#FUSES LPT1OSC                  //Timer1 configured for low-power operation
//#FUSES T1DIG                 
//#FUSES MSSPMSK7             
//#FUSES DSWDT2147483648       
#FUSES NODSWDT                 
#FUSES NODSBOR                 
#FUSES RTCOSC_T1             
#FUSES DSWDTOSC_INT         
#FUSES WPFP

#define led1 pin_b0
#define led2 pin_b1
#define led3 pin_b2
#define led4 pin_b3
#define led5 pin_b4

//#use delay(clock=20000000)


#pin_select U2TX=PIN_C4
#pin_select U2RX=PIN_C5

#use rs232(uart1,baud=9600,parity=N,bits=8,stream=uar1)
#use rs232(uart2,baud=9600,parity=N,bits=8,stream=uar2)

void main()
{
   //setup_oscillator(OSC_8MHZ|OSC_INTRC);
   setup_adc_ports(NO_ANALOGS|VSS_VDD);
   setup_adc(ADC_OFF|ADC_TAD_MUL_0);
   setup_spi(SPI_SS_DISABLED);
   setup_wdt(WDT_OFF);
   setup_timer_0(RTCC_INTERNAL);
   //setup_timer_1(T1_DISABLED);
   setup_timer_2(T2_DISABLED,0,1);
   setup_comparator(NC_NC_NC_NC);
   setup_vref(FALSE);
//Setup_Oscillator parameter not selected from Intr Oscillator Config tab

   // TODO: USER CODE!!

while(1){
 
output_toggle(led1);
//fputc('1',uar1);
fprintf(uar2,"uart:%c\r\n",'2');
delay_ms(500);

}


}
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