Roman Black's btc Sound with PIC ASM

Thread Starter

ozirock

Joined Jan 13, 2011
47
Hi,

I'm trying to use a look up table created with Roman Black's btc .wav file encoder but I'm not sure how to do it. I've been looking at examples of reading from tables using the following sort of code:

Rich (BB code):
PC   equ  02


movlw  03
call       table

:
table     addwf   PC
retlw     01
retlw     02
retlw     03
retlw     04
retlw     05
retlw     06
retlw     07

return
However the generated file comes out in blocks of 256 bytes and has:

Rich (BB code):
     org (1 * 256)   	    ; block = 1
at the top of the table instead:

Rich (BB code):
table     addwf   PC
So what I want to know really is how I call the table?

Thanks,
Oisin
 

Thread Starter

ozirock

Joined Jan 13, 2011
47
Thanks for the suggestion Mark, I've been playing around for a while now but it seem's the pic just isn't big enough, it gives the following warning:

Rich (BB code):
Address exceeds maximum range for this processor.
for all the table after it reaches:

Rich (BB code):
	     org (2 * 256)   	    ; block = 2
from the page you pointed me towards, I think this is when it moves to "Page2" which I can only assume doesn't exist on a PIC 16f627 given the error.

It was only a gimmick I wanted to add anyway so no major loss really :)
 

Markd77

Joined Sep 7, 2009
2,806
Try org d'512' instead of org (2*256).
However first check how much memory your program already uses (view, memory gauge) and pick a multiple of 256 that is bigger.
The 16f627 only has 1024 program memory, the 16f628 has 2048 and is otherwise the same.
 

Thread Starter

ozirock

Joined Jan 13, 2011
47
The memory gauge shows two dials, the first program memory shows 610 used of a total 1024 the second called data memory shows 0 of 224.

Your suggestion of changing to org d'512' worked but the sound was still much bigger than could be stored on the pic, it carried onto over 6000. I might try find simpler sounds or just leave it out altogether.
 

jackal5671

Joined Jul 12, 2011
1
Hi,

I'm trying to use a look up table created with Roman Black's btc .wav file encoder but I'm not sure how to do it. I've been looking at examples of reading from tables using the following sort of code:

Rich (BB code):
PC   equ  02


movlw  03
call       table

:
table     addwf   PC
retlw     01
retlw     02
retlw     03
retlw     04
retlw     05
retlw     06
retlw     07

return
However the generated file comes out in blocks of 256 bytes and has:

Rich (BB code):
     org (1 * 256)   	    ; block = 1
at the top of the table instead:

Rich (BB code):
table     addwf   PC
So what I want to know really is how I call the table?

Thanks,
Oisin
I had a similar problem and finally got it solved thanks to these posts. Thanks guys!
 

THE_RB

Joined Feb 11, 2008
5,438
Correct! To access tables of a full 256 bytes you need to use PCLATH to set the page the table is on, then use a computed "call" to retrieve the table entry. Microchip do have an example in an appnote somewhere, possibly the one Markd77 linked to.

The big problem with most PICs is they don't have much ROM and you only get a second or two of sound even on something like a 16F877.
 
Top