PIC programming LCD countdown timer

Markd77

Joined Sep 7, 2009
2,806
I've looked a bit further and I think the problem is most likely the table reads. Search for AN556 on the Microchip site which explains it better than I can. It's only a problem for the tables after 0xFF so it's probably possible to move the tables further up the code and avoid the problem that way.
 

Thread Starter

bluebrakes

Joined Oct 17, 2009
253
thanks very much for this...

I believe you have cracked the problem.

Now where to start?

The problem is with some of those techniques is they use the W register, however i'm already using it for alot of my loop routines.
 

Markd77

Joined Sep 7, 2009
2,806
You can either refactor your loop routines to use a normal file instead of W, copy W to a file and then restore it after, or instead of: (example 3A in AN556)
movlw HIGH Table
movwf PCLATH
movlw offset
call Table
you could use:

clrf PCLATH
incf PCLATH, F
call Table
on the condition that you know that Table is in bank 1. W would already be loaded with the offset in your loop.
You will probably find that you write your next project very differently based on what you learn from this one.
 

Thread Starter

bluebrakes

Joined Oct 17, 2009
253
Yeah, lesson learnt with this one... It was going so well until I got to the point of writing the actual timer routine.

This sounds a goood suggestion...

clrf PCLATH
incf PCLATH, F
call Table
Do you think this would be the easiest method and is this something i can just paste into place?
 

Markd77

Joined Sep 7, 2009
2,806
Should be fine for tables in page 1. If any of the tables are in page 0 use the same but skip the incf part. PCLATH is a bit of a PITA but you only have to worry about it when you change PCL directly.
 

Thread Starter

bluebrakes

Joined Oct 17, 2009
253
i just can't seem to get any of this to work...

i tried mark's suggestion of the PCLATH method, but i can't seem to get this to either.

it's really annoying.... i feel like i want to start from scratch with the programming.

I've attached a PDF of my code at the point where everything works but requires some form of fix for it to work from here on.

i'm not expecting people to rewrite my code for me :D, but any pointers would be greatly appreciated.
 

Attachments

Last edited:

Markd77

Joined Sep 7, 2009
2,806
I've had another look - I lost all the formatting because PDF is rubbish.
I moved all the tables to the end and added an org 0x0300 before them.
At the start I set PCLATH to 3 so any time a table read is done PCLATH is correct.
It's a horrible solution, and I wouldn't recommend it, but it will get things working. It only works at all because there are less than 1 page worth of tables.
I've added a retlw 0x00 that was missing from SngBeep.
It is now falling over at Switch1 because you call Switch1 but then goto some point before it. It's the other type of stack overflow problem.

Now the tables aren't causing problems you should be able to fix it.
 

Attachments

Thread Starter

bluebrakes

Joined Oct 17, 2009
253
Mark you are an absolute star!

I T W O R K S ! ! ! :D:D:D:D:D

Thank you very much for your time and patience.

I just need to do the final touches with regards to the timer itself but it's at a stage far greater stage than it was. I'm close to finishing it now.

I definately owe you a beer.
 
sorry to interrupt with a question. I want to know if you want to do electrical engineering, how many classes are required for you to take in college? because i wanted to double major: electrical and fine arts.
 

Thread Starter

bluebrakes

Joined Oct 17, 2009
253
This was a personal project as a hobby not a college assignment. Strangely, I have done very little in the way of courses on the subject and am completely self taught.

I would like to do a degree in electrical engineering at some point though...

Although what country are you from?

I'm sure someone on here will be able to help...
 

R!f@@

Joined Apr 2, 2009
10,004
sorry to interrupt with a question. I want to know if you want to do electrical engineering, how many classes are required for you to take in college? because i wanted to double major: electrical and fine arts.
U know. I was just reading this post since it is concerning PIC's.
I just can't keep my self from asking cause it keeps bugging me.
I have seen in a lot of forums tis situation.

See this thread is something else and this guy who joined 2 years before, pops up with his very first post, and asks something that is completely irrelevant to the thread, I mean does not he see the intro ur self sticky's and all those initiation thread when he first came here.

I just couldn't help asking. It's been nagging me for a while now.
Is it some that stupid or dumb, :confused: not being rude or anything here.

By the way, nice project. I would like to try tht code for my self, It's like a hobby thing. :D
 
Top