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

delay_ms not working!

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



Joined: 17 Aug 2005
Posts: 316
Location: Perth, Western Australia

View user's profile Send private message Visit poster's website

delay_ms not working!
PostPosted: Sun Jul 01, 2007 10:46 am     Reply with quote

So far I've spent probably 5 hours at this (which I can't believe!!!)! The system is to interface to an ENC28J60, and obtains its clock from the 6.25MHz CLKOUT of that chip (I intend to reconfigure that to 25MHz later on). I've checked the frequency with a scope. It's pretty square with some ringing at the level changes. The PIC is a 18LF2620 operating at 3.3V (so there shouldn't be any logic level issues between it and the ENC).

I'm also using the uart, which I've forced to software - the idea being to test the use delay instruction. The message is received by my PC without errors.

The problem I have is that the delay_ms may as well not be there. On startup, the LED (two leg bi-colour) goes straight to green and the serial message appears on my PC. There is no delay!

I'm using the v4.042 compiler, but I downgraded temporarily to v4.033 (the only other version I have) and the results were the same.

I reckon I'm missing something obvious, but can't work out what it could be!

The code I'm testing with follows:

test.h
Code:
#include <18F2620.h>
#device adc=8

#FUSES NOWDT                    //No Watch Dog Timer
#FUSES WDT128                   //Watch Dog Timer uses 1:128 Postscale
#FUSES EC_IO                    //External clock
#FUSES NOPROTECT                //Code not protected from reading
#FUSES NOBROWNOUT               //No brownout reset
#FUSES BORV21                   //Brownout reset at 2.1V
#FUSES PUT                      //Power Up Timer
#FUSES NOCPD                    //No EE protection
#FUSES STVREN                   //Stack full/underflow will cause reset
#FUSES DEBUG                    //Debug mode for ICD
#FUSES NOLVP                    //No Low Voltage Programming on B3(PIC16) or B5(PIC18)
#FUSES NOWRT                    //Program memory not write protected
#FUSES NOWRTD                   //Data EEPROM not write protected
#FUSES NOIESO                   //Internal External Switch Over mode disabled
#FUSES NOFCMEN                  //Fail-safe clock monitor disabled
#FUSES NOPBADEN                 //PORTB pins are configured as digital I/O on RESET
#FUSES NOWRTC                   //configuration not registers write protected
#FUSES NOWRTB                   //Boot block not write protected
#FUSES NOEBTR                   //Memory not protected from table reads
#FUSES NOEBTRB                  //Boot block not protected from table reads
#FUSES NOCPB                    //No Boot Block code protection
#FUSES LPT1OSC                  //Timer1 configured for low-power operation
#FUSES MCLR                     //Master Clear pin enabled
#FUSES XINST                    //Extended set extension and Indexed Addressing mode enabled

#use delay(clock=6,250,000)
#use rs232(baud=4800,parity=N,xmit=PIN_C6,rcv=PIN_C7,bits=8,force_sw)


test.c
Code:
#include "test.h"

#define LED_1A PIN_C2
#define LED_1K PIN_B3
#define LED_2A PIN_A6
#define LED_2K PIN_B4

void main()
{
   output_low(LED_1A);
   output_low(LED_1K);
   output_low(LED_2A);
   output_low(LED_2K);
   // LED red
   output_high(LED_1A);
   delay_ms(10000);
   // LED green
   output_low(LED_1A);
   output_high(LED_1K);
   puts("Test v0.1 " __DATE__ " " __TIME__);
   for(;;);
}


Any pointers or whacks with the clue stick would be greatly appreciated!
_________________
Andrew
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sun Jul 01, 2007 10:52 am     Reply with quote

Quote:
#FUSES XINST

Change this to NOXINST. CCS doesn't support the extended instruction
set, and enabling it can cause erratic operation.
andrewg



Joined: 17 Aug 2005
Posts: 316
Location: Perth, Western Australia

View user's profile Send private message Visit poster's website

PostPosted: Sun Jul 01, 2007 11:04 am     Reply with quote

Far out - that was quick! And spot on too! Thank you so much!

So, it would appear I've spent hours chasing a setting put in by default by the project wizard, that isn't supported, and screws up the project? Mad
_________________
Andrew
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sun Jul 01, 2007 11:43 am     Reply with quote

Email CCS tech support and tell them about it. If they're setting XINST
as the default, they need to correct it, and quickly. They ought to take
it out of the list of fuse options entirely and always set it to NOXINST.
That would be the safe thing to do.
andrewg



Joined: 17 Aug 2005
Posts: 316
Location: Perth, Western Australia

View user's profile Send private message Visit poster's website

PostPosted: Sun Jul 01, 2007 10:57 pm     Reply with quote

PCM programmer wrote:
Email CCS tech support and tell them about it.
Done. Thanks again for your help.
_________________
Andrew
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