gnupic: Re: [gnupic] about data tables and shared variables


Previous by date: 30 Aug 2008 18:57:37 -0000 Re: [gnupic] about data tables and shared variables, Jerry Zdenek
Next by date: 30 Aug 2008 18:57:37 -0000 Re: [gnupic] about data tables and shared variables, Peter Stuge
Previous in thread: 30 Aug 2008 18:57:37 -0000 Re: [gnupic] about data tables and shared variables, Jerry Zdenek
Next in thread: 30 Aug 2008 18:57:37 -0000 Re: [gnupic] about data tables and shared variables, Peter Stuge

Subject: Re: [gnupic] about data tables and shared variables
From: Lope Vega ####@####.####
Date: 30 Aug 2008 18:57:37 -0000
Message-Id: <579044.47123.qm@web28202.mail.ukl.yahoo.com>

Thanks a lot guys,

I've got it now more or less solved.

Also, the problem with shared variables was solved as you pointed out Jerry, my fault was placing the `global digit' before it's declaration itself, as I also tried what you said before.

Just beg me another question, though.

What I'm trying to do is to have a switch counting till 100, which after reached, will get set back to 0; all of this while being displayed whatever the current value of the counter variable on these three seven segment displays.

My question is about how to handle it. Should I place on my main function the debouncing routine for the switch, and then perhaps an interrupt for timer0 so the actual `count' will get displayed all the time? or would be better the opossite way, or anyother I can't think of?

I haven't got a clue on how structure the program to handle this while not letting it get blocked either, because of waiting for debouncing (display flickers), or for updating the display (not giving the switch the priority it deserves).

Many thanks,


--- El sáb, 30/8/08, Jerry Zdenek ####@####.#### escribió:

> De: Jerry Zdenek ####@####.####
> Asunto: Re: [gnupic] about data tables and shared variables
> Para: ####@####.####
> Fecha: sábado, 30 agosto, 2008 5:55
> The CALL instruction doesn't update PCLATH.  So when you
> add W to PCL, 
> PC[15:8] gets whatever is left in PCLATH, causing you to
> jump apparently 
> randomly.  Set PCLATH  first and you should be fine.  You
> should also 
> make sure PCLATU is cleared just in case it got changed, as
> that gets 
> fed into PC as well.
> 
> This should work (but I haven't tried it):
> 
>   my_table_code  code  0x200
> 
>   my_table:
> 
>     movwf  temp_var
> 
>     clrf  PCLATU
>     movlw HIGH my_table
>     movwf PCLATH
> 
>     movf	 tmp_var,W
> 
>     addwf pcl, f
>     retlw b'01000000' ; number 0
>     ....
> 
> As for your second problem, at least in MPASM, you need to
> declare your 
> variable global as such:
>     GLOBAL my_global_var
> 
> And then when you use it:
>     extern my_global_var
> 
> Jerry
> 
> 
> Noel Henson wrote:
> > I've had some trouble in the past with this.
> Don't know if this will help 
> > but try placing a NOP after the addwf PCL,f. The other
> thing you will want 
> > to check is to make sure that your table does not
> cross a 256-byte 
> > boundary. If it does, you could actually be branching
> to to before the 
> > beginning of the table when you access table values
> that are above the next 
> > 256-byte boundary.
> > 
> > I hope this helps,
> > 
> > Noel
> > 
> > On Saturday 30 August 2008, Lope Vega wrote:
> >> Hello again guys,
> >>
> >> First of all, do you recall in my last message
> when I said all the
> >> problems dissapeared for me as soon as I grounded
> RB3? My mistake, I was
> >> tryin to refer to RB5, which I've even read
> within the specs, should be
> >> grounded whether it's not being used.
> >>
> >> Said and solved that, I'm running into two
> problems I cannot cope with,
> >> and for which I'd be glad to hear anything
> about.
> >>
> >> One of them is about data tables. I'm trying
> to drive 3 7-segment
> >> displays which I've got multiplexed. Since I
> don't really yet understand
> >> table reads/writes, and haven't seen an
> example which adequates to what
> >> I'm doing, I thought on using `computed
> gotos':
> >>
> >> ; make sure they're placed at the begining of
> a page
> >> my_table_code  code  0x200
> >>
> >> my_table:
> >>   addwf pcl, f
> >>   retlw b'01000000' ; number 0
> >>   ......            ; number 1
> >>
> >> display:
> >>   ; call my table, which will use the value on the
> `w' register
> >>   call my_table
> >>   ; actually display the number
> >>   movwf latb
> >>   ; and return
> >>   retlw 0x0
> >>
> >> The problem I'm having is that the PC gets
> lost.
> >>
> >> Though I've been reading within the
> piclist's archives about how to
> >> solve it (working arround with PCLATH), I
> haven't been able to, so if
> >> anyone knows of some example code about this, or
> about using table reads
> >> I can apply to this, or even could write some
> example code I could start
> >> off with, that would be great.
> >>
> >> The other problem I'm finding is about shared
> variables, which would
> >> make my life much easier. I have changed the line:
> >>
> >> DATABANK   NAME=usb4       START=0x400         
> END=0x4FF         
> >> PROTECTED
> >>
> >> within the default linker script for the
> pic18f4550, with:
> >> SHAREBANK  NAME=usb4       START=0x400         
> END=0x4FF
> >>
> >> I've read the specs says it is risky at best
> to do this (because of
> >> dynamic buffers' allocation policy it claims)
> but I won't be using USB
> >> by now, and any of the ways, as far as I can tell
> the problem I'm having
> >> hasn't got nothing to do with it, as I've
> tried with other script's
> >> lines.
> >>
> >> My problem is that if I define a udata_shr block
> let's say in my main
> >> file:
> >>
> >> myvars  udata_shr
> >> my_global_var  res 1
> >>
> >> Then, whenever I try to use it on other module I
> get an "`my_global_var
> >> symbol is undefined" message, and I
> haven't seen some sort of "global"
> >> or "extern" directive I should use so as
> to let my other module know
> >> that was a variable declared as shared within the
> main one.
> >>
> >> Any comments appreciated,
> >>
> >> Many Thanks.
> >>
> >>
> >>
> >> __________________________________________________
> >> Correo Yahoo!
> >> Espacio para todos tus mensajes, antivirus y
> antispam ¡gratis!
> >> Regístrate ya - http://correo.yahoo.es
> >>
> >>
> >>
> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail:
> ####@####.####
> >> For additional commands, e-mail:
> ####@####.####
> > 
> > 
> > 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ####@####.####
> For additional commands, e-mail:
> ####@####.####

__________________________________________________
Correo Yahoo!
Espacio para todos tus mensajes, antivirus y antispam ¡gratis! 
Regístrate ya - http://correo.yahoo.es 


Previous by date: 30 Aug 2008 18:57:37 -0000 Re: [gnupic] about data tables and shared variables, Jerry Zdenek
Next by date: 30 Aug 2008 18:57:37 -0000 Re: [gnupic] about data tables and shared variables, Peter Stuge
Previous in thread: 30 Aug 2008 18:57:37 -0000 Re: [gnupic] about data tables and shared variables, Jerry Zdenek
Next in thread: 30 Aug 2008 18:57:37 -0000 Re: [gnupic] about data tables and shared variables, Peter Stuge


Powered by ezmlm-browse 0.20.