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

Timer3 config byte cannot be written to

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



Joined: 20 Jul 2008
Posts: 32
Location: Brisbane, Australia

View user's profile Send private message

Timer3 config byte cannot be written to
PostPosted: Sun Sep 21, 2008 5:03 am     Reply with quote

I am using PCWH (4.079), with a 18F2620 and trying to get Timer3 going. Generating a simple test program using the wizard I end up with the line "setup_timer_3(T3_INTERNAL|T3_DIV_BY_8)" in the code. The bracket evaluates to 0xB5. This all seems ok.

If I look at the assembly generated I see

"0054: MOVLW B5
0056: MOVWF FB1"

And this all seems fine.

Now if I use the debugger and run the program and read back FB1 (after stopping at an appropriate place), I get "0x0" and timer3 shows no signs of working because reading RAM FB2 and FB3 always return 0x0, whenever I stop the program. This is just a very simple test program with a loop added after the code generated by the wizard, so there is no oppurtunity to overwrite FB1.

I have been able to get timer0 to timer2 working (in other programs) as might be expected, so the problem seems to be isolated to timer3.

I have a problem help # from CCS, have now had it for quite a few weeks and the problem does not appear to be addressed each time a new compiler version has come out. Hopefully they will eventually get to it.

In the mean time, if anybody has any thoughts on this (in case its more than a compiler bug) I would appreciate it.

Thanks
FvM



Joined: 27 Aug 2008
Posts: 2337
Location: Germany

View user's profile Send private message

PostPosted: Sun Sep 21, 2008 6:39 am     Reply with quote

Hello,

I just tested with V4.079 and a PIC18F2455, that also has the Timer3 and found this:

The Timer3 related registers aren't displayed correctly in PCW debugger, although the timer is operating regularly (as should be expected from the assembly code).

In the below code, you can see the variable test receiving an incremented
value.
Code:
   setup_timer_3(T3_INTERNAL|T3_DIV_BY_8);
   // some other code
   test = get_timer3();


I also have an ICD2, an it is showing the Timer3 registers correctly. So I think, you just found another V4 bug.

Regards,
Frank
Ttelmah
Guest







PostPosted: Sun Sep 21, 2008 7:05 am     Reply with quote

I'd say a debugger problem....
I just compiled the following:
Code:

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

#FUSES NOWDT,WDT128,RC,NOPROTECT,NOIESO,BROWNOUT
#FUSES BORV21,NOPUT,NOCPD,STVREN,NODEBUG,NOLVP
#FUSES NOWRT,NOWRTD,NOEBT,NOCPB,NOEBTRB,NOWRTC                   
#FUSES NOWRTB,FCMEN,NOXINST,PBADEN,FUSES LPT1OSC                 
#FUSES MCLR

#use delay(clock=4MHZ)
#use rs232(baud=9600,parity=N,xmit=PIN_C6,rcv=PIN_C7,bits=8)

void main() {
   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_timer_3(T3_INTERNAL|T3_DIV_BY_8);
   while(true) {
      delay_cycles(1);
   }
}

Compiled it, and run it up on my ICE. Address 0xFB1, is set to 0xB5, and after a few loops, 0xFB2, is happily counting away.
Obvious comment - make sure that NOXINST is set. Otherwise this can cause all sorts of oddities (CCS does not support this fuse).

Seriously, if the assembler shown inside your ICD/ICE, matches the assembler listing (B5, is being loaded into 0xFB1), then it _cannot_ be a compiler problem, but has to be with what you are running it on.....

Best Wishes
Herbert



Joined: 20 Jul 2008
Posts: 32
Location: Brisbane, Australia

View user's profile Send private message

PostPosted: Mon Sep 22, 2008 5:14 am     Reply with quote

Frank, I inserted your bit of suggested code and yep, it does read back a continuously incrementing timer3. So beneath the debugger there is a working timer! Thanks very much for the suggestion, its good getting a different perspective on an issue.

Ttelmah, thanks for your suggestion as well. I find the CCS wizard has generated the NOXINST line into the header file.

You are both right, its the CCS debugger. Means I have to go back to more "primitive" techniques to check the code operation around timer3!
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