[SOLVED] Problem with TMR0 prescaler when changing from HI-TECH PICC v9.60 tov9.71a

Status
Not open for further replies.

niala72

Newbie level 6
Joined
May 28, 2014
Messages
12
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Visit site
Activity points
115
I have developped a product with a PIC 16F505. The hardware is stable (at least 100 boards finished).

I decided to make modifications but the computer with Win2000 and the 9.60 compiler is out. Now it is XP SP3 and a new C compiler with also MPLAB v 8.91.00.00 and an ICD2.5 (ICD2 before).

After a few hours I found that the prescaler does not want to work with the timer (it worked with the old software).

Code:
OPTION = 0b11010010; before

Code:
OPTION = 0b11011010; now if I want to use the timer (no prescaler)

I see that I can read and write to TMR0, use the same condition do {...} while (TMR0 != 0); but the timer des not increase if I use the prescaler (PSA=0), the loop does not finish.

I have switched off optimization, looked at the code produced, I do not find any explanation.

I can't debug becaus I have no ICD Header AC162059. Anyway I think the problem comes form the prescaler but why ???

Thanks for any help.

Alain
 
Last edited by a moderator:

Seriously speaking, I don't understand why it shouldn't be possible to reproduce all SFR settings that have worked before with the compiler version.
 

I suppose that the startup code is not the same, and may be there is a problem inside the compiler ?

I have seen in the past a particular do while structure that didn't work properly.

Here I have searched if an unwanted write to timer had been added which could reset the prescaler without my agreement. I think the prescaler does not run but it cannot be read nor written.

If I have no other solution I will use the timer without prescaler and divide by soft, I will modify all the structure of the main loop.
 

Hello,

I have used my old computer with PICC 9.60 and the prescaler runs with timer 0. Due to optimization and new technology of the compiler it is not easy to compare lst files. With the 9.71a this is the problem :

Code:
    // PSA=0 does not run
    OPTION = 0b11010111;
Code:
   // PSA=1 is running
//    OPTION = 0b11011010;
There is only one line which seems to produce bad running. But I cannot make without the prescaler and I would prefer utilizing the computer with the last compiler version.

It would also be interesting to understand.
 
Last edited by a moderator:

Hello,

a friend of me had a look wednesday at the listings and had also disassembled the hex files to see if a starang thing was on the startup part. And after about two hours He as found THE PROBLEM.

For the working program, timer test is like this :

46 1EF l7
47 ;main.c: 63: do {} while (TMR0 != 0);
48 1EF 064 clrf 4
49 1F0 201 movf 1,w ;volatile
50 1F1 743 btfss 3,2
51 1F2 BEF goto l7

For the bad code, it is :

152 1ED l470:
153 1ED 221 movf 1,f
154 1EE 743 skipz
155 1EF BED goto l470


They write the reg 1 (tmr0) on itself to position flags. It does not change timer content if it runs slowly, but when the timer is written the prescaler IS RESET so it stays equal to 00 !!!

VERY BAD COMPILER
 

Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…