Roman Black's btc Sound with PIC ASM

Discussion in 'Embedded Systems and Microcontrollers' started by ozirock, Mar 11, 2011.

  1. ozirock

    Thread Starter Member

    Jan 13, 2011
    44
    0
    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:

    Code ( (Unknown Language)):
    1. PC   equ  02
    2.  
    3.  
    4. movlw  03
    5. call       table
    6.  
    7. :
    8. table     addwf   PC
    9. retlw     01
    10. retlw     02
    11. retlw     03
    12. retlw     04
    13. retlw     05
    14. retlw     06
    15. retlw     07
    16.  
    17. return
    However the generated file comes out in blocks of 256 bytes and has:

    Code ( (Unknown Language)):
    1.      org (1 * 256)          ; block = 1  
    at the top of the table instead:

    Code ( (Unknown Language)):
    1. table     addwf   PC
    So what I want to know really is how I call the table?

    Thanks,
    Oisin
     
  2. Markd77

    Senior Member

    Sep 7, 2009
    2,803
    594
  3. ozirock

    Thread Starter Member

    Jan 13, 2011
    44
    0
    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:

    Code ( (Unknown Language)):
    1. Address exceeds maximum range for this processor.
    for all the table after it reaches:

    Code ( (Unknown Language)):
    1.          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 :)
     
  4. Markd77

    Senior Member

    Sep 7, 2009
    2,803
    594
    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.
     
  5. ozirock

    Thread Starter Member

    Jan 13, 2011
    44
    0
    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.
     
  6. jackal5671

    New Member

    Jul 12, 2011
    1
    0
    I had a similar problem and finally got it solved thanks to these posts. Thanks guys!
     
  7. ferguson

    New Member

    Sep 12, 2011
    1
    0
    helpful instructions, guys :) thank you a lot. i get used to dealing with implementing a table read via different method..
     
  8. THE_RB

    AAC Fanatic!

    Feb 11, 2008
    5,435
    1,305
    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.
     
Loading...