Hello Fabio,
When I suggested you post your assembly code, I did not actually mean to send me the code via PM. The purpose of the forum is to provide for open discussion of the topics raised, with the assumption that any answers given might possibly help others, as well as yourself.
With this in mind, the following is the contents of the PM -
Fabio wrote:
Hello!
hanks for the respost and excuse me for 3 times of the identical question.
I cannot read a table with dates of a one byte with the LDX command, I wrong command or I to do use other command/instruction.
The tabs in future is 256 byte for generate a PWM 8 bit sine, the tab in the attach is only for example of data read.
I don't understand way it dosen't work, so if any body can help me I will appreciate it.
Thank you very much!
Fabio
mainLoop:
; Insert your code here
LDHX #$F4
STHX TPMC1V
MOV #$28,TPMSC
mainLoop1
NOP
ldX #TabSin-1
aix #1
pshh
pshx
lda x
STHX TPMC1V
MOV #$28,TPMSC
pulx
pulh
feed_watchdog
STA SRS ; feed the watchdog
BRA mainLoop1
XDEF TabSin
; tabella generazione sinusoide
TabSin:
ds.b 10
dc.w 50
dc.w 50
Firstly, your requirements for TPM use are totally unclear to me. There seems to be some confusion about timer overflow operation, and timer channel operation. Substantial revision of the code in this area is likely to be necessary.
But to address your actual query concerning reading byte values from a data table ...
- If the table is to consist of data bytes (not words), the directive dc.b must be used consistently, not ds.b or dc.w as you currently have. Note that dc.b 10,50,50 is also permissible, to reduce the number of lines. You will need to refer to the CW assembler manual for information about assembler directives.
- The most straighforward way to read a single byte value from the table (of size not exceeding 256 bytes) -
Firstly set X-register to the table index value that you require (0-255), then use the following instructions to fetch the byte value in the accumulator.
CLRH
LDA TabSin,X
After processing each byte, if you then need to increment the index value in order to read the next byte, either of the following instructions could be used, even though operation is a little different in each case -
INCX
or
AIX #1
Regards,
Mac
Message Edited by bigmac on
2007-06-02 03:10 AM