ljbeng
Joined: 10 Feb 2004 Posts: 205
|
18F25J11 PCWHD 4.108 |
Posted: Thu Nov 18, 2010 11:42 am |
|
|
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);
}
}
|
|
|