Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

sine LUT problem...

Status
Not open for further replies.

kvrajasekar

New Member
Hi all,

I am trying to call the sine LUT values.Totally 120 values are stored in LUT. PIC16f72.

When i am trying to access the values,i can get 110 values only.I posted my code here,please tell me what is the problem...

sine_loop

movf offctr,w
call sine_LUT
movwf vref_val
movf offctr,w
sublw 0x80
btfsc STATUS,Z
goto loopcompleted ;else continue.
incf offctr,1
goto sine_loop

sine_LUT
addwf PCL,F ; Increment into table

dt .0,.7,.13,.20,.27,.33,.40,.47,.53,.60,.66,.73,.79,.85,.92,.98,.104,.110,.116,.122,.128,.134,.139,.145,.150
dt .156,.161,.166,.171,.176,.181,.186,.190,.195,.199,.203,.207,.211,.215,.218,.222,.225,.228,.231,.234,.237,.239
dt .241,.243,.245,.247,.249,.250,.252,.253,.255,.255,.255,.255,.255,.255,.255,.255,.255,.254,.253,.252,.250
dt .249,.247,.245,.243,.241,.239,.237,.234,.231,.228,.225,.222,.218,.215,.211,.207,.203,.199,.195,.190,.186,.181,.176,.171,.166,.161,.156,.150,.145,.139,.134,.128
dt .122,.116,.110,.104,.98,.92,.85,.79,.73,.66,.60,.53,.47,.40,.33,.27,.20,.13,.7,.0
end
 
Last edited:
Thanks for the reply...

Is it necessary to use PCLATH?I studied some where, PCLATH is not necessary to add ...for 2k limit chip ...
 
Thanks for the reply...

Is it necessary to use PCLATH?I studied some where, PCLATH is not necessary to add ...for 2k limit chip ...

hi,
The datasheet explains the change to your table call that is required for crossing boundaries. PCLATH is used.

BTW: there is an error in your table. .60,.5 3,.47,

EDIT:

Code:
BRG_TABLE			;PLACE ALL THE BEARINGS HERE
  	MOVLW  TABLESTART		;SETUP PCLATH FOR THE TABLE
  	ADDWF  TABLEOFF + 1, W
  	MOVWF  PCLATH
  	MOVLW  TABLESTART & 0X0FF	;OFFSET
  	ADDWF  TABLEOFF, W
  	BTFSC  STATUS, C		;IF NECESSARY, INCREMENT PCLATH
   	INCF  PCLATH, F		;TO GET THE CORRECT 256 ADDRESS PAGE
  	MOVWF  PCL			;UPDATE THE PC

TABLESTART			; bearing data
 
Last edited:
Thanks for notifying the mistake.

I used 90 degrees sine LUT instead of 180 degrees,so it is within the boundary limit.I think no need to add PCLATH.
 
Thanks for notifying the mistake.

I used 90 degrees sine LUT instead of 180 degrees,so it is within the boundary limit.I think no need to add PCLATH.

I have EDITED my last post with a PCLATH subr.

As you have noted a 90deg table is all that is required for a sine wave.

BTW: another option is to have an other ORIGIN at a boundary, higher in memory and start the table there.
 
Last edited:
Thanks Mr.eric,

But i didnt get how to use the PCLATH in my program.I did the following,

sine_loop

movf offctr,w
call sine_LUT
movwf vref_val
movf offctr,w
sublw 0x80
btfsc STATUS,Z
goto loopcompleted ;else continue.
incf offctr,1
goto sine_loop

sine_LUT
addwf pcl,f
dt 0x99,0x23......


Please help me,how can i go with PCLATH.




-Raja.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top