Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > sci.electronics.design > #381124 > unrolled thread
| Started by | Robert Baer <robertbaer@localnet.com> |
|---|---|
| First post | 2015-10-11 23:17 -0700 |
| Last post | 2015-10-12 23:52 -0700 |
| Articles | 19 on this page of 39 — 6 participants |
Back to article view | Back to sci.electronics.design
OT: Reformatted update on table call problem Robert Baer <robertbaer@localnet.com> - 2015-10-11 23:17 -0700
Re: OT: Reformatted update on table call problem piglet <erichpwagner@hotmail.com> - 2015-10-12 09:17 +0100
Re: OT: Reformatted update on table call problem Robert Baer <robertbaer@localnet.com> - 2015-10-12 19:11 -0700
Re: OT: Reformatted update on table call problem Martin Brown <|||newspam|||@nezumi.demon.co.uk> - 2015-10-13 08:17 +0100
Re: OT: Reformatted update on table call problem Robert Baer <robertbaer@localnet.com> - 2015-10-13 22:26 -0700
Re: OT: Reformatted update on table call problem piglet <erichpwagner@hotmail.com> - 2015-10-14 07:50 +0100
Re: OT: Reformatted update on table call problem Robert Baer <robertbaer@localnet.com> - 2015-10-14 16:35 -0700
Re: OT: Reformatted update on table call problem Martin Brown <|||newspam|||@nezumi.demon.co.uk> - 2015-10-15 12:01 +0100
Re: OT: Reformatted update on table call problem Robert Baer <robertbaer@localnet.com> - 2015-10-15 22:41 -0700
Re: OT: Reformatted update on table call problem piglet <erichpwagner@hotmail.com> - 2015-10-16 07:09 +0100
Re: OT: Reformatted update on table call problem Martin Brown <|||newspam|||@nezumi.demon.co.uk> - 2015-10-16 08:50 +0100
Re: OT: Reformatted update on table call problem piglet <erichpwagner@hotmail.com> - 2015-10-16 09:31 +0100
Re: OT: Reformatted update on table call problem Robert Baer <robertbaer@localnet.com> - 2015-10-17 21:34 -0700
Re: OT: Reformatted update on table call problem piglet <erichpwagner@hotmail.com> - 2015-10-18 09:42 +0100
Re: OT: Reformatted update on table call problem Martin Brown <|||newspam|||@nezumi.demon.co.uk> - 2015-10-19 09:12 +0100
Re: OT: Reformatted update on table call problem Robert Baer <robertbaer@localnet.com> - 2015-10-19 23:04 -0700
Re: OT: Reformatted update on table call problem Robert Baer <robertbaer@localnet.com> - 2015-10-17 21:08 -0700
Re: OT: Reformatted update on table call problem piglet <erichpwagner@hotmail.com> - 2015-10-18 09:45 +0100
Re: OT: Reformatted update on table call problem Robert Baer <robertbaer@localnet.com> - 2015-10-19 23:08 -0700
Re: OT: Reformatted update on table call problem Robert Baer <robertbaer@localnet.com> - 2015-10-17 21:19 -0700
Re: OT: Reformatted update on table call problem piglet <erichpwagner@hotmail.com> - 2015-10-18 09:50 +0100
Re: OT: Reformatted update on table call problem Robert Baer <robertbaer@localnet.com> - 2015-10-19 23:14 -0700
Re: OT: Reformatted update on table call problem Robert Baer <robertbaer@localnet.com> - 2015-10-17 21:03 -0700
Re: OT: Reformatted update on table call problem piglet <erichpwagner@hotmail.com> - 2015-10-18 10:14 +0100
Re: OT: Reformatted update on table call problem Robert Baer <robertbaer@localnet.com> - 2015-10-19 23:31 -0700
Re: Reformatted update on table call problem "P E Schoen" <paul@pstech-inc.com> - 2015-10-20 20:30 -0400
Re: Reformatted update on table call problem Robert Baer <robertbaer@localnet.com> - 2015-10-20 22:42 -0700
Re: Reformatted update on table call problem "P E Schoen" <paul@pstech-inc.com> - 2015-10-21 14:06 -0400
Re: Reformatted update on table call problem Robert Baer <robertbaer@localnet.com> - 2015-10-23 21:01 -0700
Re: Reformatted update on table call problem "P E Schoen" <paul@pstech-inc.com> - 2015-10-24 01:08 -0400
Re: Reformatted update on table call problem krw <krw@nowhere.com> - 2015-10-24 09:05 -0400
Re: OT: Reformatted update on table call problem Martin Brown <|||newspam|||@nezumi.demon.co.uk> - 2015-10-12 09:46 +0100
Re: OT: Reformatted update on table call problem piglet <erichpwagner@hotmail.com> - 2015-10-12 10:39 +0100
Re: OT: Reformatted update on table call problem Martin Riddle <martin_ridd@verizon.net> - 2015-10-12 08:24 -0400
Re: OT: Reformatted update on table call problem Robert Baer <robertbaer@localnet.com> - 2015-10-12 19:54 -0700
Re: OT: Reformatted update on table call problem Robert Baer <robertbaer@localnet.com> - 2015-10-12 19:55 -0700
Re: OT: Reformatted update on table call problem Robert Baer <robertbaer@localnet.com> - 2015-10-12 19:49 -0700
Re: OT: Reformatted update on table call problem Robert Baer <robertbaer@localnet.com> - 2015-10-12 19:44 -0700
Re: OT: Reformatted update on table call problem (OOPS!) Robert Baer <robertbaer@localnet.com> - 2015-10-12 23:52 -0700
Page 2 of 2 — ← Prev page 1 [2]
| From | piglet <erichpwagner@hotmail.com> |
|---|---|
| Date | 2015-10-18 09:50 +0100 |
| Message-ID | <mvvmch$k5i$1@dont-email.me> |
| In reply to | #381933 |
On 18/10/2015 05:19, Robert Baer wrote: > From ASM listing: > 00038 ; From AN556 page 3, EXAMPLE 5: > 0080 00039 org 0x80 ;code location page 0 > 0080 3002 00040 movlw HIGH Table > 0081 008A 00041 movwf PCLATH > 00042 ; movlw ptrlo,F > MPASM 5.41 AN556CHK.ASM 10-12-2015 > LOC OBJECT CODE LINE SOURCE TEXT > VALUE > > 00043 > 00044 > 0082 3020 00045 movlw ptrlo > 0083 22FF 00046 call Table > 0084 2086 00047 CALL DISPL > 00048 ; Does NOT work; see 0x00, 0xFF, 0xFF, 0xFF > 0085 2810 00049 GOTO start > > > 00071 ; From AN556 page 3, EXAMPLE 4: > 02FF 00072 org 0x02ff ;Table, end of page 2 > 02FF 080A 00073 Table: MOVF PCLATH,W > 0300 2086 00074 CALL DISPL > 0301 30A5 00075 MOVLW 0xA5 > 0302 2086 00076 CALL DISPL > 0303 2810 00077 GOTO start > 0304 0782 00078 addwf PCL,F > 0305 3441 00079 retlw d'65' > 0306 3442 00080 retlw d'66' > 0307 3443 00081 retlw d'67' > What happens to the return address that was pushed to the stack at 0083, where is it popped off by a return instruction? Or in other words please tell how instructions at 0304, 0305, 0306, 0307 will get a chance to execute? Hint: please look at 0303 piglet
[toc] | [prev] | [next] | [standalone]
| From | Robert Baer <robertbaer@localnet.com> |
|---|---|
| Date | 2015-10-19 23:14 -0700 |
| Message-ID | <3ZkVx.161567$uZ5.149971@fx18.iad> |
| In reply to | #381950 |
piglet wrote: > On 18/10/2015 05:19, Robert Baer wrote: >> From ASM listing: >> 00038 ; From AN556 page 3, EXAMPLE 5: >> 0080 00039 org 0x80 ;code location page 0 >> 0080 3002 00040 movlw HIGH Table >> 0081 008A 00041 movwf PCLATH >> 00042 ; movlw ptrlo,F >> MPASM 5.41 AN556CHK.ASM 10-12-2015 >> LOC OBJECT CODE LINE SOURCE TEXT >> VALUE >> >> 00043 >> 00044 >> 0082 3020 00045 movlw ptrlo >> 0083 22FF 00046 call Table >> 0084 2086 00047 CALL DISPL >> 00048 ; Does NOT work; see 0x00, 0xFF, 0xFF, 0xFF >> 0085 2810 00049 GOTO start >> >> >> 00071 ; From AN556 page 3, EXAMPLE 4: >> 02FF 00072 org 0x02ff ;Table, end of page 2 >> 02FF 080A 00073 Table: MOVF PCLATH,W >> 0300 2086 00074 CALL DISPL >> 0301 30A5 00075 MOVLW 0xA5 >> 0302 2086 00076 CALL DISPL >> 0303 2810 00077 GOTO start >> 0304 0782 00078 addwf PCL,F >> 0305 3441 00079 retlw d'65' >> 0306 3442 00080 retlw d'66' >> 0307 3443 00081 retlw d'67' >> > > > What happens to the return address that was pushed to the stack at 0083, > where is it popped off by a return instruction? > > Or in other words please tell how instructions at 0304, 0305, 0306, 0307 > will get a chance to execute? > > Hint: please look at 0303 > > piglet > > Those are placeholders only. Note that,at line 83, the CALL Table does not work (one sees 0x00, 0xFF, 0xFF, 0xFF etc).
[toc] | [prev] | [next] | [standalone]
| From | Robert Baer <robertbaer@localnet.com> |
|---|---|
| Date | 2015-10-17 21:03 -0700 |
| Message-ID | <HSEUx.2146$vj4.821@fx05.iad> |
| In reply to | #381603 |
Martin Brown wrote:
> On 15/10/2015 00:35, Robert Baer wrote:
>> piglet wrote:
>>> On 14/10/2015 06:26, Robert Baer wrote:
>
>>>> * I have proven that PCLATH is set by the CALL - in this case to 0x0100
>>>> and not the zero that would conveniently explain the apparent
>>>> reset/cold
>>>> start.
>
> Seems unlikely since it can only hold values in the range 0x00 to 0xff.
>
>>> Are you sure? Have you mixed up PCH and PCLATH.
>>>
>>> What happens during a CALL is 11 bits of PC are loaded from the opcode
>>> (all of PCL and 3 low bits of PCH) and two bits from PCLATH go to PCH.
>>> During arith on pc then the arith changes 8 bits of PCL and all 5 bits
>>> of PCH are loaded from PCLATH. Neither arith nor CALL writes or changes
>>> the value in PCLATH. Unless you restrict your table and code using it to
>>> the first 255 locations then PCLATH has to be written to by your code
>>> before doing the table lookup.
>>>
>>> It is all in the chip datasheet.
>>>
>>> piglet
>>>
>> Concerning "datasheets, here is a code snippet:
>> ; ----------------------------------------------
>> ; From AN556 page 3, EXAMPLE 4:
>> org 0x02ff ;Table located end of page 2
>> Table:
>> addwf PCL,F ;value in pc will not roll over to page 3
>> retlw d'65' ;NOTE assembler doesn't recognize 'A' etc..
>> retlw d'66' ; so assembler will crash.
>> retlw d'67' ; Therefore used decimal equivalent
>> ; *Also discovered that PC _CAN_ indeed "rollover" to page 3, I modified
>> the
>> ; code to show that fact thus:
>> ;Table: MOVF PCLATH,W
>> ; CALL DISPL ; to show that CALL sets PCLATH (documentation
>> ; does NOT state this fact).
>> ; MOVLW 0xA5
>> ; CALL DISPL ; use unique "marker"
>> ; GOTO start ; !!! See 0x00 0xFF 0x02 0xA5 repeat (!!)
>
> WTF don't you use the software PIC emulator and single step it?
>
> Then you can watch all the registers and understand the thing properly.
>
> You might find this page informative if you are still struggling:
> http://pcbheaven.com/picpages/Program_Flow_Instructions/
>
> The problem you are having is because PCL & PCH are both 8 bits wide
> whereas the CALL and GOTO locations are 11 bits and 2bits from PCLATH.
>
> It is quite a nasty gotcha for the unwary. It is good practice to keep
> PCLATH pointed at the page where you intend to execute instructions.
>
I have not found either a simulator or an emulator; only the debug
via the use of that debug header monster.
The IDE "help" file (like all so-called help files) does not.
[toc] | [prev] | [next] | [standalone]
| From | piglet <erichpwagner@hotmail.com> |
|---|---|
| Date | 2015-10-18 10:14 +0100 |
| Message-ID | <mvvnp9$oek$1@dont-email.me> |
| In reply to | #381931 |
On 18/10/2015 05:03, Robert Baer wrote: > I have not found either a simulator or an emulator; only the debug > via the use of that debug header monster. > The IDE "help" file (like all so-called help files) does not. > I use mplab ide v8.92. Under the the tab "debugger" go to "select tool" then select MPLAB SIM. That is the inbuilt software simulator and you can single step thru your dissassembly listing with F7 key. Use the "view" tab to open additional windows on file, stack, etc etc. piglet
[toc] | [prev] | [next] | [standalone]
| From | Robert Baer <robertbaer@localnet.com> |
|---|---|
| Date | 2015-10-19 23:31 -0700 |
| Message-ID | <pdlVx.130780$5N3.19009@fx17.iad> |
| In reply to | #381952 |
piglet wrote:
> On 18/10/2015 05:03, Robert Baer wrote:
>> I have not found either a simulator or an emulator; only the debug
>> via the use of that debug header monster.
>> The IDE "help" file (like all so-called help files) does not.
>>
>
> I use mplab ide v8.92. Under the the tab "debugger" go to "select tool"
> then select MPLAB SIM. That is the inbuilt software simulator and you
> can single step thru your dissassembly listing with F7 key. Use the
> "view" tab to open additional windows on file, stack, etc etc.
>
> piglet
This is going to take some learning.
Where are the "instructions" for using this beast?
? Run to brake-point would be nice, continue another nice..
I notice that PCH does not exist ("not available").
Thanks.
[toc] | [prev] | [next] | [standalone]
| From | "P E Schoen" <paul@pstech-inc.com> |
|---|---|
| Date | 2015-10-20 20:30 -0400 |
| Subject | Re: Reformatted update on table call problem |
| Message-ID | <n06m6m$vr1$1@dont-email.me> |
| In reply to | #382137 |
"Robert Baer" wrote in message news:pdlVx.130780$5N3.19009@fx17.iad...
> This is going to take some learning.
> Where are the "instructions" for using this beast?
> ? Run to brake-point would be nice, continue another nice..
> I notice that PCH does not exist ("not available").
Here are some tutorials and other information on the IDE and software
simulator/debugger. Some may be for older versions but should be fine for
the most basic operation:
http://nnp.ucsd.edu/phy120b/pic_manuals_pdf/mplab_simu_edit_user.pdf (from
2001)
http://www.siriusmicro.com/mplabx-c.html (For MPLABX and C)
http://www.microchip.com/developmenttools/getting_started/gs_mplab3.aspx
(IDE 6.6)
https://www.youtube.com/watch?v=pnkUOL0mmyA (from 2008)
http://ww1.microchip.com/downloads/en/DeviceDoc/MPLAB_User_Guide_51519c.pdf
(2009)
http://www.puntoflotante.net/EASY-GUIDE-TO-THE-MPLAB-IDE-SIMULATOR.pdf
http://ww1.microchip.com/downloads/en/DeviceDoc/52027B.pdf (MPLABX 2011)
It would be very helpful to study and understand the finer points of the IDE
and simulator, and the basic operation of the Microchip devices. PICs are
very powerful, especially newer versions, and with such power comes
responsibility to know their capabilities and the tools to program them. It
is a steep learning curve, but well worth the effort. Otherwise, perhaps it
would be good to use the Arduino or BASIC stamp or other simplified
platforms.
Paul
[toc] | [prev] | [next] | [standalone]
| From | Robert Baer <robertbaer@localnet.com> |
|---|---|
| Date | 2015-10-20 22:42 -0700 |
| Subject | Re: Reformatted update on table call problem |
| Message-ID | <RAFVx.134692$fA1.69561@fx21.iad> |
| In reply to | #382228 |
P E Schoen wrote:
> "Robert Baer" wrote in message news:pdlVx.130780$5N3.19009@fx17.iad...
>
>> This is going to take some learning.
>> Where are the "instructions" for using this beast?
>> ? Run to brake-point would be nice, continue another nice..
>
>> I notice that PCH does not exist ("not available").
>
> Here are some tutorials and other information on the IDE and software
> simulator/debugger. Some may be for older versions but should be fine
> for the most basic operation:
>
> http://nnp.ucsd.edu/phy120b/pic_manuals_pdf/mplab_simu_edit_user.pdf
> (from 2001)
>
> http://www.siriusmicro.com/mplabx-c.html (For MPLABX and C)
>
> http://www.microchip.com/developmenttools/getting_started/gs_mplab3.aspx
> (IDE 6.6)
>
> https://www.youtube.com/watch?v=pnkUOL0mmyA (from 2008)
>
> http://ww1.microchip.com/downloads/en/DeviceDoc/MPLAB_User_Guide_51519c.pdf
> (2009)
>
> http://www.puntoflotante.net/EASY-GUIDE-TO-THE-MPLAB-IDE-SIMULATOR.pdf
>
> http://ww1.microchip.com/downloads/en/DeviceDoc/52027B.pdf (MPLABX 2011)
>
> It would be very helpful to study and understand the finer points of the
> IDE and simulator, and the basic operation of the Microchip devices.
> PICs are very powerful, especially newer versions, and with such power
> comes responsibility to know their capabilities and the tools to program
> them. It is a steep learning curve, but well worth the effort.
> Otherwise, perhaps it would be good to use the Arduino or BASIC stamp or
> other simplified platforms.
>
> Paul
Thanks!
Fortunately, i had about half of those, so saved download time.
[toc] | [prev] | [next] | [standalone]
| From | "P E Schoen" <paul@pstech-inc.com> |
|---|---|
| Date | 2015-10-21 14:06 -0400 |
| Subject | Re: Reformatted update on table call problem |
| Message-ID | <n08k3e$7sb$1@dont-email.me> |
| In reply to | #382267 |
"Robert Baer" wrote in message news:RAFVx.134692$fA1.69561@fx21.iad...
> P E Schoen wrote:
>
>> Here are some tutorials and other information on the IDE and software
>> simulator/debugger. Some may be for older versions but should be fine for
>> the most basic operation:
>
> http://nnp.ucsd.edu/phy120b/pic_manuals_pdf/mplab_simu_edit_user.pdf
> (from 2001)
>
> http://www.siriusmicro.com/mplabx-c.html (For MPLABX and C)
>
> http://www.microchip.com/developmenttools/getting_started/gs_mplab3.aspx
> (IDE 6.6)
>
> https://www.youtube.com/watch?v=pnkUOL0mmyA (from 2008)
>
> http://ww1.microchip.com/downloads/en/DeviceDoc/MPLAB_User_Guide_51519c.pdf
> (2009)
>
> http://www.puntoflotante.net/EASY-GUIDE-TO-THE-MPLAB-IDE-SIMULATOR.pdf
>
> http://ww1.microchip.com/downloads/en/DeviceDoc/52027B.pdf (MPLABX 2011)
>
>> It would be very helpful to study and understand the finer points of the
>> IDE and simulator, and the basic operation of the Microchip devices. PICs
>> are very powerful, especially newer versions, and with such power comes
>> responsibility to know their capabilities and the tools to program them.
>> It is a steep learning curve, but well worth the effort.
>> Otherwise, perhaps it would be good to use the Arduino or BASIC stamp or
>> other simplified platforms.
> Thanks!
> Fortunately, i had about half of those, so saved download time.
It would also help to know just what you are trying to do, and why you chose
the device you are using and why you are programming in assembler. At one
point it seemed you were making a sine table, and elsewhere it seemed like
an ASCII look-up. For a sine table and similar math functions, it may be
better to use an actual sine function, or a table with a few data points and
cubic spline* (or similar) interpolation to get good accuracy. There are
always trade-offs between code size and complexity, and speed, however.
Here is a link to a sine table implementation:
http://www.brouhaha.com/~eric/pic/sine.html
Other resources:
http://www.piclist.com/techref/microchip/math/index.htm
Paul
*Here is a simple spline function in C
/*****************************************************************************
This spline function returns a floating point y value for the given
x_value
n is the number of points in the input array
*****************************************************************************/
float spline( float x_val, int n, float *x, float *y )
{
float y_val = 0;
float num, den;
int i,j;
for (i=0; i<n; i++)
{
num = 1;
for (j=0; j<n; j++)
{
if (j != i)
num *= (x_val - x[j]);
}
den = 1;
for (j=0; j<n; j++)
{
if (j != i)
den *= (x[i] - x[j]);
}
y_val += (y[i] * ( num/den ) );
}
return(y_val);
}
[toc] | [prev] | [next] | [standalone]
| From | Robert Baer <robertbaer@localnet.com> |
|---|---|
| Date | 2015-10-23 21:01 -0700 |
| Subject | Re: Reformatted update on table call problem |
| Message-ID | <noDWx.221341$HZ6.79224@fx12.iad> |
| In reply to | #382321 |
P E Schoen wrote:
> "Robert Baer" wrote in message news:RAFVx.134692$fA1.69561@fx21.iad...
>
>> P E Schoen wrote:
>>
>>> Here are some tutorials and other information on the IDE and software
>>> simulator/debugger. Some may be for older versions but should be fine
>>> for the most basic operation:
>>
>> http://nnp.ucsd.edu/phy120b/pic_manuals_pdf/mplab_simu_edit_user.pdf
>> (from 2001)
>>
>> http://www.siriusmicro.com/mplabx-c.html (For MPLABX and C)
>>
>> http://www.microchip.com/developmenttools/getting_started/gs_mplab3.aspx
>> (IDE 6.6)
>>
>> https://www.youtube.com/watch?v=pnkUOL0mmyA (from 2008)
>>
>> http://ww1.microchip.com/downloads/en/DeviceDoc/MPLAB_User_Guide_51519c.pdf
>>
>> (2009)
>>
>> http://www.puntoflotante.net/EASY-GUIDE-TO-THE-MPLAB-IDE-SIMULATOR.pdf
>>
>> http://ww1.microchip.com/downloads/en/DeviceDoc/52027B.pdf (MPLABX 2011)
>>
>>> It would be very helpful to study and understand the finer points of
>>> the IDE and simulator, and the basic operation of the Microchip
>>> devices. PICs are very powerful, especially newer versions, and with
>>> such power comes responsibility to know their capabilities and the
>>> tools to program them. It is a steep learning curve, but well worth
>>> the effort.
>
>>> Otherwise, perhaps it would be good to use the Arduino or BASIC stamp
>>> or other simplified platforms.
>
>> Thanks!
>> Fortunately, i had about half of those, so saved download time.
>
> It would also help to know just what you are trying to do, and why you
> chose the device you are using and why you are programming in assembler.
> At one point it seemed you were making a sine table, and elsewhere it
> seemed like an ASCII look-up. For a sine table and similar math
> functions, it may be better to use an actual sine function, or a table
> with a few data points and cubic spline* (or similar) interpolation to
> get good accuracy. There are always trade-offs between code size and
> complexity, and speed, however.
>
> Here is a link to a sine table implementation:
> http://www.brouhaha.com/~eric/pic/sine.html
>
> Other resources:
> http://www.piclist.com/techref/microchip/math/index.htm
>
> Paul
>
> *Here is a simple spline function in C
>
> /*****************************************************************************
>
> This spline function returns a floating point y value for the given x_value
> n is the number of points in the input array
> *****************************************************************************/
>
>
> float spline( float x_val, int n, float *x, float *y )
>
> {
> float y_val = 0;
> float num, den;
> int i,j;
>
> for (i=0; i<n; i++)
> {
> num = 1;
> for (j=0; j<n; j++)
> {
> if (j != i)
> num *= (x_val - x[j]);
> }
> den = 1;
> for (j=0; j<n; j++)
> {
> if (j != i)
> den *= (x[i] - x[j]);
> }
> y_val += (y[i] * ( num/den ) );
> }
> return(y_val);
> }
The device was chosen by someone else; i am stuck with it.
Use of tables is necessary because the actual waveform(s) will be
complex and arbitrary; the sine (triangle and square) waves were for
reference.
[toc] | [prev] | [next] | [standalone]
| From | "P E Schoen" <paul@pstech-inc.com> |
|---|---|
| Date | 2015-10-24 01:08 -0400 |
| Subject | Re: Reformatted update on table call problem |
| Message-ID | <n0f3lb$d1g$1@dont-email.me> |
| In reply to | #382542 |
"Robert Baer" wrote in message news:noDWx.221341$HZ6.79224@fx12.iad... > The device was chosen by someone else; i am stuck with it. It seems odd that someone else can make a design decision to use a particular microcontroller and (presumably) hardware design, yet require you to provide the code to make it work. > Use of tables is necessary because the actual waveform(s) will be > complex and arbitrary; the sine (triangle and square)waves were for > reference. For arbitrary waveforms, it seems that perhaps a separate EEPROM might be good for storage of the waveform data. It could even be clocked into a D/A converter which is generally much better for waveform generation than PWM, which is the usual method for microcontrollers. It's a common trap to become focused on a particular methodology to accomplish a given task, when something else might be much more efficient or superior by virtue of various metrics. Paul
[toc] | [prev] | [next] | [standalone]
| From | krw <krw@nowhere.com> |
|---|---|
| Date | 2015-10-24 09:05 -0400 |
| Subject | Re: Reformatted update on table call problem |
| Message-ID | <movm2bhilkcjsefuf8get0pp41s56lf36h@4ax.com> |
| In reply to | #382543 |
On Sat, 24 Oct 2015 01:08:54 -0400, "P E Schoen" <paul@pstech-inc.com> wrote: >"Robert Baer" wrote in message news:noDWx.221341$HZ6.79224@fx12.iad... > >> The device was chosen by someone else; i am stuck with it. > >It seems odd that someone else can make a design decision to use a >particular microcontroller and (presumably) hardware design, yet require you >to provide the code to make it work. Happens all the time. In the real world, there are often other system (and sometimes political/business) constraints that determine the hardware used. > >> Use of tables is necessary because the actual waveform(s) will be >> complex and arbitrary; the sine (triangle and square)waves were for >> reference. > >For arbitrary waveforms, it seems that perhaps a separate EEPROM might be >good for storage of the waveform data. It could even be clocked into a D/A >converter which is generally much better for waveform generation than PWM, >which is the usual method for microcontrollers If the micro is already there, the same thing can be done with the micro, of course. > >It's a common trap to become focused on a particular methodology to >accomplish a given task, when something else might be much more efficient or >superior by virtue of various metrics. > It's also common to not include all of the constraints when stating a problem.
[toc] | [prev] | [next] | [standalone]
| From | Martin Brown <|||newspam|||@nezumi.demon.co.uk> |
|---|---|
| Date | 2015-10-12 09:46 +0100 |
| Message-ID | <mvfs0s$ekf$1@speranza.aioe.org> |
| In reply to | #381124 |
On 12/10/2015 07:17, Robert Baer wrote: > > LIST p=P16F648A > #include P16F648A.inc > ; Was P16F628A > __CONFIG _CP_OFF & _WDT_OFF & _PWRTE_OFF & _HS_OSC & > _LVP_OFF & _MCLRE_OFF & _BOREN_OFF > __IDLOCS 0x0001 > > ; VARIABLES > ptrlo EQU 0x20 ; table pointer > ptrhi EQU 0x21 > COUNT1 EQU 0x22 ; delay counter > COUNT2 EQU 0x23 > COUNT3 EQU 0x24 > sSTATUS EQU 0x25 > sW EQU 0x26 > ; > ORG 0x0000 > GOTO start > GOTO start > GOTO start > GOTO start > ORG 0x0010 > start: ;** setup I/O > ; All pins have 10K in series with an LED to GND except OSC pins (and GND) > > CLRF PORTB ; Set all Port B pins to logic 0 > BSF RB3,RB5 ; Bank 1 command comes next STATUS RP0 set > CLRF PORTB ; sel all Port B pins as outputs > BCF RB3,RB5 ; Bank 0 command comes next STATUS RP0 clear > > CLRF ptrlo ; start offset pointers at zero > CLRF ptrhi > > CLRW > MOVWF PORTB ; Port B to zero > CALL DELAY ; "freeze" LEDs > > MOVLW 0xFF > MOVWF PORTB ; Port B ones > CALL DELAY ; "freeze" LEDs > > repeat: > INCF ptrlo ; next loc > MOVF ptrlo,W > CALL tab1 ;;*REMoving this, one sees 0x00 0xFF (counting) > ; otherwise,one sees only repeating 0x00 0xFF > MOVWF PORTB ; Port B from W > CALL DELAY ; "freeze" LEDs > GOTO repeat > ; ---------------------------------------------- > DELAY MOVWF sW > ; MOVF STATUS,W > ; MOVWF sSTATUS > CLRF COUNT1 > CLRF COUNT2 > MOVLW d'45' ; fudge for about 4 Sec delay > MOVWF COUNT3 > LUPINR DECFSZ COUNT1 > GOTO LUPINR > DECFSZ COUNT2 > GOTO LUPINR > DECFSZ COUNT3 > GOTO LUPINR > DEXIT: ; MOVF sSTATUS,W > ; MOVWF STATUS > MOVF sW,W > RETURN > ; ---------------------------------------------- sine > ORG 0x0100 > tab1: > ;; RETLW 0x01 ; [0] t=0.7500 r=0.0000 > ADDWF PCL,F > RETLW 0x15 ; [1] t=0.7539 r=0.0240 > RETLW 0x14 ; [2] t=0.7578 r=0.0964 > RETLW 0x13 ; [3] t=0.7617 r=0.2173 > RETLW 0x12 ; [4] t=0.7656 r=0.3865 > > Note the CALL tab1 does not work. > Why? PCLATH is still zero! Single step it in the emulator!!! Try this for a concrete example of what you seem to be trying to do: http://www.piclist.com/techref/microchip/bigtable.htm -- Regards, Martin Brown
[toc] | [prev] | [next] | [standalone]
| From | piglet <erichpwagner@hotmail.com> |
|---|---|
| Date | 2015-10-12 10:39 +0100 |
| Message-ID | <mvfv15$q1a$1@dont-email.me> |
| In reply to | #381144 |
On 12/10/2015 09:46, Martin Brown wrote: > > PCLATH is still zero! Single step it in the emulator!!! > Well spotted Martin! The Call instruction loads 11 of the 13 PC bits so PCLATH only needs to be set for distant calls but the add-to-pc instruction only loads the lower 8 bits of PC so PCLATH cannot be ignored. See section 4.3 of the datasheet page 30. piglet
[toc] | [prev] | [next] | [standalone]
| From | Martin Riddle <martin_ridd@verizon.net> |
|---|---|
| Date | 2015-10-12 08:24 -0400 |
| Message-ID | <3h9n1b1uli7hf10fa25272g1ulet2t7jur@4ax.com> |
| In reply to | #381146 |
On Mon, 12 Oct 2015 10:39:42 +0100, piglet <erichpwagner@hotmail.com> wrote: >On 12/10/2015 09:46, Martin Brown wrote: >> >> PCLATH is still zero! Single step it in the emulator!!! >> > >Well spotted Martin! > >The Call instruction loads 11 of the 13 PC bits so PCLATH only needs to >be set for distant calls but the add-to-pc instruction only loads the >lower 8 bits of PC so PCLATH cannot be ignored. See section 4.3 of the >datasheet page 30. > >piglet When PCL is updated, PCH ==> PCLATH. Besides his table is at 100h, move it to 50h and it works. Cheers
[toc] | [prev] | [next] | [standalone]
| From | Robert Baer <robertbaer@localnet.com> |
|---|---|
| Date | 2015-10-12 19:54 -0700 |
| Message-ID | <En_Sx.8$q7.7@fx11.iad> |
| In reply to | #381152 |
Martin Riddle wrote: > On Mon, 12 Oct 2015 10:39:42 +0100, piglet<erichpwagner@hotmail.com> > wrote: > >> On 12/10/2015 09:46, Martin Brown wrote: >>> >>> PCLATH is still zero! Single step it in the emulator!!! >>> >> >> Well spotted Martin! >> >> The Call instruction loads 11 of the 13 PC bits so PCLATH only needs to >> be set for distant calls but the add-to-pc instruction only loads the >> lower 8 bits of PC so PCLATH cannot be ignored. See section 4.3 of the >> datasheet page 30. >> >> piglet > > When PCL is updated, PCH ==> PCLATH. > Besides his table is at 100h, move it to 50h and it works. > > Cheers > Yes, ONLY because it would be in the first page, aka 0X0000. DAMN, the 6502 was infinitely better.......................
[toc] | [prev] | [next] | [standalone]
| From | Robert Baer <robertbaer@localnet.com> |
|---|---|
| Date | 2015-10-12 19:55 -0700 |
| Message-ID | <Wo_Sx.9$q7.4@fx11.iad> |
| In reply to | #381152 |
Martin Riddle wrote: > On Mon, 12 Oct 2015 10:39:42 +0100, piglet<erichpwagner@hotmail.com> > wrote: > >> On 12/10/2015 09:46, Martin Brown wrote: >>> >>> PCLATH is still zero! Single step it in the emulator!!! >>> >> >> Well spotted Martin! >> >> The Call instruction loads 11 of the 13 PC bits so PCLATH only needs to >> be set for distant calls but the add-to-pc instruction only loads the >> lower 8 bits of PC so PCLATH cannot be ignored. See section 4.3 of the >> datasheet page 30. >> >> piglet > > When PCL is updated, PCH ==> PCLATH. > Besides his table is at 100h, move it to 50h and it works. > > Cheers > Thanks everyone for the solution to my hair-puller.
[toc] | [prev] | [next] | [standalone]
| From | Robert Baer <robertbaer@localnet.com> |
|---|---|
| Date | 2015-10-12 19:49 -0700 |
| Message-ID | <ej_Sx.16807$e36.7841@fx06.iad> |
| In reply to | #381146 |
piglet wrote: > On 12/10/2015 09:46, Martin Brown wrote: >> >> PCLATH is still zero! Single step it in the emulator!!! >> > > Well spotted Martin! > > The Call instruction loads 11 of the 13 PC bits so PCLATH only needs to > be set for distant calls but the add-to-pc instruction only loads the > lower 8 bits of PC so PCLATH cannot be ignored. See section 4.3 of the > datasheet page 30. > > piglet > Check; confirms that the CALL instruction can f* you royally.
[toc] | [prev] | [next] | [standalone]
| From | Robert Baer <robertbaer@localnet.com> |
|---|---|
| Date | 2015-10-12 19:44 -0700 |
| Message-ID | <he_Sx.10$bT2.2@fx19.iad> |
| In reply to | #381144 |
Martin Brown wrote: > On 12/10/2015 07:17, Robert Baer wrote: >> >> LIST p=P16F648A >> #include P16F648A.inc >> ; Was P16F628A >> __CONFIG _CP_OFF & _WDT_OFF & _PWRTE_OFF & _HS_OSC & >> _LVP_OFF & _MCLRE_OFF & _BOREN_OFF >> __IDLOCS 0x0001 >> >> ; VARIABLES >> ptrlo EQU 0x20 ; table pointer >> ptrhi EQU 0x21 >> COUNT1 EQU 0x22 ; delay counter >> COUNT2 EQU 0x23 >> COUNT3 EQU 0x24 >> sSTATUS EQU 0x25 >> sW EQU 0x26 >> ; >> ORG 0x0000 >> GOTO start >> GOTO start >> GOTO start >> GOTO start >> ORG 0x0010 >> start: ;** setup I/O >> ; All pins have 10K in series with an LED to GND except OSC pins (and >> GND) >> >> CLRF PORTB ; Set all Port B pins to logic 0 >> BSF RB3,RB5 ; Bank 1 command comes next STATUS RP0 set >> CLRF PORTB ; sel all Port B pins as outputs >> BCF RB3,RB5 ; Bank 0 command comes next STATUS RP0 clear >> >> CLRF ptrlo ; start offset pointers at zero >> CLRF ptrhi >> >> CLRW >> MOVWF PORTB ; Port B to zero >> CALL DELAY ; "freeze" LEDs >> >> MOVLW 0xFF >> MOVWF PORTB ; Port B ones >> CALL DELAY ; "freeze" LEDs >> >> repeat: >> INCF ptrlo ; next loc >> MOVF ptrlo,W >> CALL tab1 ;;*REMoving this, one sees 0x00 0xFF (counting) >> ; otherwise,one sees only repeating 0x00 0xFF >> MOVWF PORTB ; Port B from W >> CALL DELAY ; "freeze" LEDs >> GOTO repeat >> ; ---------------------------------------------- >> DELAY MOVWF sW >> ; MOVF STATUS,W >> ; MOVWF sSTATUS >> CLRF COUNT1 >> CLRF COUNT2 >> MOVLW d'45' ; fudge for about 4 Sec delay >> MOVWF COUNT3 >> LUPINR DECFSZ COUNT1 >> GOTO LUPINR >> DECFSZ COUNT2 >> GOTO LUPINR >> DECFSZ COUNT3 >> GOTO LUPINR >> DEXIT: ; MOVF sSTATUS,W >> ; MOVWF STATUS >> MOVF sW,W >> RETURN >> ; ---------------------------------------------- sine >> ORG 0x0100 >> tab1: >> ;; RETLW 0x01 ; [0] t=0.7500 r=0.0000 >> ADDWF PCL,F >> RETLW 0x15 ; [1] t=0.7539 r=0.0240 >> RETLW 0x14 ; [2] t=0.7578 r=0.0964 >> RETLW 0x13 ; [3] t=0.7617 r=0.2173 >> RETLW 0x12 ; [4] t=0.7656 r=0.3865 >> >> Note the CALL tab1 does not work. >> Why? > > PCLATH is still zero! Single step it in the emulator!!! > > Try this for a concrete example of what you seem to be trying to do: > > http://www.piclist.com/techref/microchip/bigtable.htm > > If that is true,no wonder it acts like a system reset every time thru the loop! SO that means the CALL instruction is lame as all hell, and the "working" examples are useless. "Documentation" on the CALL shows that an eleven-bit address is used for the jump; the doc for the PIC shows: (PC)+1-->TOS k-->PC<10:0)>, (PCLATH<4:3>)-->PC<12:11> So...you are right, PCLATH remains zero, as that was the page the program was on at the CALL. So the CALL allows one to jump to ANY 4K address within a 2K block as set by PCLATH. But after that, ignoring a return, one is stuck with addressing within a 256 location range at best. And if that puts one on a different page (16 of them in each aligned block), then tough tissue paper as they say in Southern Russia. Gee..i can, with seven-league boots, walk around 1/2 of the world, but then must mince on tippie-toes afterwords. Not exactly conducive to sanity. Thanks! PS: I bet that NONE of the samples in that reference actually work.
[toc] | [prev] | [next] | [standalone]
| From | Robert Baer <robertbaer@localnet.com> |
|---|---|
| Date | 2015-10-12 23:52 -0700 |
| Subject | Re: OT: Reformatted update on table call problem (OOPS!) |
| Message-ID | <cT1Tx.16461$p53.10301@fx07.iad> |
| In reply to | #381281 |
Robert Baer wrote:
** clipped out **
> PS: I bet that NONE of the samples in that reference actually work.
>
Well, I coded Example 4 from AN556 and had to fix a number of coding
problems.
But saw the exact same problem.
Decided to "snoop" PCLTH and...the CALL does indeed set PCLATH from
the CALL contents.
Curious.
And also found an anomaly that is puzzling...
The program will indeed "roll over" into the next page with nary an
eyeblink.
THAT is decidedly _different_ than what their comment states.
Program:
LIST p=P16F648A
#include P16F648A.inc
; Was P16F628A
__CONFIG _CP_OFF & _WDT_OFF & _PWRTE_OFF & _HS_OSC &
_LVP_OFF & _MCLRE_OFF & _BOREN_OFF
__IDLOCS 0x0001
; VARIABLES
ptrlo EQU 0x20 ; table pointer
ptrhi EQU 0x21
COUNT1 EQU 0x22 ; DISPL counters
COUNT2 EQU 0x23
COUNT3 EQU 0x24
sSTATUS EQU 0x25 ; save STATUS here
sW EQU 0x26 ; save W here
;
ORG 0x0000
GOTO start
GOTO start
GOTO start
GOTO start
ORG 0x0010
start: ;** setup I/O
; All pins have 10K in series with an LED to GND except OSC pins and GND
CLRF PORTB ; Set all Port B pins to logic 0
BSF RB3,RB5 ; Bank 1 command comes next STATUS RP0 set
CLRF PORTB ; sel all Port B pins as outputs
BCF RB3,RB5 ; Bank 0 command comes next STATUS RP0 clear
CLRF ptrlo ; start offset pointers at zero
CLRF ptrhi
CLRW
CALL DISPL ; "freeze" LEDs
MOVLW 0xFF
CALL DISPL ; "freeze" LEDs
;* remember PCLATH=0 as we are in page zero (ORG 0x0010)
repeat:
; From AN556 page 3, EXAMPLE 4:
org 0x80 ;code location in page 0
movlw HIGH Table ;load PCLATH with hi address
movwf PCLATH ; /
; movlw ptrlo,F ;load offset in w reg
; ^----- NOTE illegal character
; NOTE "offset" not defined in example; used own defined variable
movlw ptrlo ;Used CORRECT form to load offset in w reg
call Table
CALL DISPL ; "freeze" LEDs
; NOTE: Does NOT work; displays 0x00, 0xFF, 0xFF, 0xFF etc
GOTO start
; ----------------------------------------------
DISPL
MOVWF PORTB ; Port B from W for display
MOVWF sW
MOVF STATUS,W
MOVWF sSTATUS
CLRF COUNT1
CLRF COUNT2
MOVLW d'50' ; fudge for about 2 Sec display
MOVWF COUNT3
LUPINR DECFSZ COUNT1
GOTO LUPINR
DECFSZ COUNT2
GOTO LUPINR
DECFSZ COUNT3
GOTO LUPINR
DEXIT: MOVF sSTATUS,W
MOVWF STATUS
MOVF sW,W
RETURN
; ----------------------------------------------
; From AN556 page 3, EXAMPLE 4:
org 0x02ff ;Table located end of page 2
Table: MOVF PCLATH,W
CALL DISPL ; "freeze" LEDs
MOVLW 0xA5
CALL DISPL ; "freeze" LEDs
GOTO start ; !!! See 0x00 0xFF 0x02 0xA5 repeat (!!)
addwf PCL,F ;value in pc will not roll over to page 3
retlw d'65' ;NOTE assembler doesn't recognize 'A' etc..
retlw d'66' ; so assembler will crash.
retlw d'67' ; Therefore used decimal equivalent.
END
** Note indented code is added for "snooping" PCLATH right at entry to
table.
[toc] | [prev] | [standalone]
Page 2 of 2 — ← Prev page 1 [2]
Back to top | Article view | sci.electronics.design
csiph-web