Forum - MCS Electronics

 

FAQFAQ SearchSearch RegisterRegister Log inLog in

VS1002d Code
Goto page Previous  1, 2
 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    www.mcselec.com Forum Index -> BASCOM-AVR Archive
View previous topic :: View next topic  
Author Message
Gmccomb

Bascom Member



Joined: 25 Mar 2006
Posts: 12

blank.gif
PostPosted: Wed Mar 29, 2006 3:52 am    Post subject: Reply with quote

superbrad wrote:

I'm not sure why AVR-DOS has problems with that. I was thinking maybe it was just a problem on my computer, but I guess not. I've never been able to get it to work without messing around with the FS_Interpreter.bas file.


Brad, Well, make it at least two with this problem! Anyway, thanks for the verification. I was wondering if some of my files were out of date, but I fetched the latest of everything, and the same thing.

It looks like I'll need to write a custom-implementation for Flash card access as AVR-DOS needs far too large of a footprint. It really makes zero sense these days to use a Mega128 to build an MP3 player, as you can now purchase a basic player for $20-25. No one will be interested in spending $100 for parts, and the M128 makes it harder because it's not available in DIP.

In another thread ATIU suggested going over some of the C-based code others have used to create lightweight AVR-based MP3 players, and this is probably what I'll have to do. If anyone is interested in co-opping on this project, let me know. What I'm looking to do is produce the project using ONLY Bascom AVR -- the project need only read one file at a time and play it back under MCU control. Playback is from basic serial commands, not pushbuttons. I know it can be done in C, but Bascom is more approachable. Being able to load this onto the $20 Butterfly (16K Flash, 1K RAM) is a design goal.

FWIW, I've also tried another clone basic for AVR from mikroElektronika. They have some FAT and memory card libraries, but to date I can't get any of them to work (the product is relatively new, but the EasyAVR3 board is nice, and I prefer it over my STK500 for routine development work). The footprint in another clone basic for an MMC-based app is about 4KB Flash and under 1K for RAM, which is about what I'm after. But I think I'd prefer to do this with Bascom as it's a more mature product.

-- Gordon
Back to top
View user's profile
Gmccomb

Bascom Member



Joined: 25 Mar 2006
Posts: 12

blank.gif
PostPosted: Wed Mar 29, 2006 3:55 am    Post subject: Reply with quote

Oh, that's funny!! The board is censoring that "other product" and turning it into "*unoriginal basic*"!!

Anyway, folks should know what I'm talking about.

-- Gordon
Back to top
View user's profile
superbrad

Bascom Member



Joined: 18 Sep 2005
Posts: 62

usa.gif
PostPosted: Wed Mar 29, 2006 5:42 pm    Post subject: Reply with quote

Quote:
It looks like I'll need to write a custom-implementation for Flash card access as AVR-DOS needs far too large of a footprint.


You might start with trying to chop down AVR-DOS. You won't be able to get near the 1K RAM limit on the butterfly like you want, but it sure beats writing it all yourself. The other thing is AVR-DOS was written in assembly ... that makes it pretty difficult to get more efficient, but it all depends on what kind of features you want. Directory browsing? File manipulation? My MP3 player will need it, but I guess it all depends on what you need.
Back to top
View user's profile AIM Address Yahoo Messenger MSN Messenger
Gmccomb

Bascom Member



Joined: 25 Mar 2006
Posts: 12

blank.gif
PostPosted: Wed Mar 29, 2006 6:04 pm    Post subject: Reply with quote

For me, I think going from C examples (there are several for the AVR) to Bascom will be easier than paring down AVR-DOS, and besides, I'm not sure the AVR-DOS license allows for that except for personal use. This project is intended to be republished.

The MP3 player I'm working on is for playback of sounds/music under a separate MCU (via serial), where you simply indicate the filename you want to play. Filenames would be known, so directory browsing or lists aren't necessary, nor is recording or anything else. You might, for example, use such a system to create a playback unit for a store display that responds in some certain way when someone walks by.
Back to top
View user's profile
papa_of_t

Bascom Member



Joined: 18 Jul 2005
Posts: 88

blank.gif
PostPosted: Thu Mar 30, 2006 9:19 am    Post subject: Reply with quote

Hi Gmccomb,

If you don't really need a file system support, you can read sectors instead files. there you can read byte by byte from an SD-Card and feed to your sound chip. The only small problem you may have is that you need to fill the card with pure sound data properly and no file headers etc. Question is if you really want to do so, it is some work to take the sd-card datasheet, initialize properly, then READ_MULTIPLE_SECTORS i.E. - that's the advantage that AVR-Dos gives.

_________________
Carsten,
with greetings from the nice city of Berlin
Back to top
View user's profile
moreau

Bascom Member



Joined: 27 Jan 2005
Posts: 43

france.gif
PostPosted: Thu Mar 30, 2006 12:34 pm    Post subject: mp3 player VS10xx Reply with quote

I am using a VS1011b for a mp3 player, work fine with a derivate of
the source find in the forum.
Very thanks to provide it!
Back to top
View user's profile
superbrad

Bascom Member



Joined: 18 Sep 2005
Posts: 62

usa.gif
PostPosted: Thu Mar 30, 2006 5:06 pm    Post subject: Reply with quote

Thanks, Moreau, I'm glad to hear it was useful!
Back to top
View user's profile AIM Address Yahoo Messenger MSN Messenger
Gmccomb

Bascom Member



Joined: 25 Mar 2006
Posts: 12

blank.gif
PostPosted: Thu Mar 30, 2006 6:23 pm    Post subject: Reply with quote

papa_of_t wrote:

If you don't really need a file system support, you can read sectors instead files.


Thanks for the idea, but file support is pretty important. The files will be copied onto the media using an ordinary media reader on a PC -- a $15-$25 accessory, assuming the PC doesn't already have a media slot. To make using the MP3 easier, each file is referenced by name using a simple serial command.

Fortunately, I think the project can stand to require certain assumptions, such as FAT16 and not FAT32, only an MMC/SD card, 8+3 filenames, and no directories. This should make the coding easier, and the memory footprint, which is critical.
Back to top
View user's profile
bzijlstra

Bascom Ambassador



Joined: 30 Dec 2004
Posts: 1179
Location: Tilburg - Netherlands

netherlands.gif
PostPosted: Sat Apr 01, 2006 1:09 pm    Post subject: Lowlevel read/write routines.... Reply with quote

There are some low level read and write routines for ATA harddisk and Compact flash on my homepage. Perhaps not exactly what you are looking for but perhaps you get the idea...

Have fun
Ben Zijlstra
Back to top
View user's profile Visit poster's website
papa_of_t

Bascom Member



Joined: 18 Jul 2005
Posts: 88

blank.gif
PostPosted: Mon May 22, 2006 3:09 pm    Post subject: sinus test Reply with quote

Hi Superbrad and other sound freaks,

finally i have my sparkfun VS1002 board now and i want to start with a sine test as described in the data sheet. I tried with portions of your code as you see below, only difference is that I use ATMega8 and different pins for communication, it runs 1MHz and on 3,0 instead 3,0 Volt. The portion of code below runs until the end, but i don't here anything - even if I can see the communication if I scope the SO/SI lines - could somebody have a look or do a test - to find out what's wrong? Of course I will also do Smile

Code:
      Led = 0

      'Hardware reset
      Xreset = 1
      Waitms 10
      Xreset = 0
      Waitms 10
      Xreset = 1
      Waitms 10

      Gosub Waitfordreq
      Waitms 500

      'set test mode, see sparkfun example
      Vs_write &H0 , &HC , &H20
      Gosub Waitfordreq

      'send test sequence
      Xcs = 0

      B =&H53
      Shiftout Vs_mosi , Vs_clock , B , 1
      Gosub Waitfordreq

      B = &HEF
      Shiftout Vs_mosi , Vs_clock , B , 1
      Gosub Waitfordreq

      B = &H6E
      Shiftout Vs_mosi , Vs_clock , B , 1
      Gosub Waitfordreq

      B = 126
      Shiftout Vs_mosi , Vs_clock , B , 1
      Gosub Waitfordreq

      For I = 1 To 4
            B = &H00
            Shiftout Vs_mosi , Vs_clock , B , 1
            Gosub Waitfordreq
      Next I

      Xcs = 1
      Led = 0

      'End
      Do
            Toggle Ptest
      Loop


Waitfordreq:
      Do
            Led = Dreq
      Loop Until Dreq = 1
      Waitus 5
Return



 

_________________
Carsten,
with greetings from the nice city of Berlin
Back to top
View user's profile
superbrad

Bascom Member



Joined: 18 Sep 2005
Posts: 62

usa.gif
PostPosted: Fri May 26, 2006 1:18 am    Post subject: Reply with quote

Hmm ... Is this all the program part of the code you're using or just a snippet? Have you initialized the VS1002 yet? If I remember right, you'll need to at least set the crystal speed before it will work correctly. I'll try to check it out more later when I'm at home and have the code in front of me.

Best luck,
Brad
Back to top
View user's profile AIM Address Yahoo Messenger MSN Messenger
papa_of_t

Bascom Member



Joined: 18 Jul 2005
Posts: 88

blank.gif
PostPosted: Mon May 29, 2006 1:08 pm    Post subject: Reply with quote

Hi, this is just a part of the code. Meanwhile i changed a little because i use hardware SPI now, but this should make no big difference. Thank you very much that you want to try. Below and attached is my complete actual test code. I tryed with it to adapt the example of the sparkfun site:

http://www.sparkfun.com/datasheets/PCB/vs1002_Sine_Test_Tone.c


Code:
$regfile = "m8def.dat"                                      'ATmega8-Deklarationen
$crystal = 1000000
$hwstack = 128
$swstack = 128
$framesize = 128

Declare Function Spi_transfer(byval Spi_byte As Byte) As Byte
Declare Sub Vs_write_spi(byval Vs_address As Byte , Byval Data1 As Byte , Byval Data2 As Byte)

Const Vs_rd = &B0000_0011                                   'Write command
Const Vs_wr = &B0000_0010                                   'Read command

Dim B As Byte
Dim H As Byte
Dim H2 As Byte
Dim I As Long

'Alias
Led Alias Portb.0
Miso Alias Pinb.4
Mosi Alias Portb.3
Clock Alias Portb.5
Xcs Alias Portc.4
Dreq Alias Pinb.1
Xreset Alias Portc.5
Ptest Alias Portd.7
'also connected as Vs1002 board:
'left,rigth.gbuf -> audio socket
'rx, DCS/bsync -> pull up
'3V / gnd
'all other pins NC

'direction
Config Led = Output                                         'for test
Config Miso = Input                                         'SO
Config Mosi = Output                                        'SI
Config Clock = Output                                       'SCLK
Config Xcs = Output                                         'cs
Config Dreq = Input                                         'DREQ
Config Xreset = Output                                      'reset
Config Ptest = Output                                       'for test


'Ports einstellen
Ddrb = &B11101101

Spcr = &B01010011
   ' Bit7=0:IntAus,
   ' Bit6=1:SPIan,
   ' Bit5=0:MSBfirst,
   ' Bit4=1:Master,
   ' Bit3=0:Clock 0 when Idle,
   ' Bit2 PHASE on leading edge,   ?
   ' Bit 1/0 = SPITakt, 00 = schnellstes
'spix2 = ON, dadurch SPI speed = clock / 2
Spsr.0 = 1


'****************************************************
'***********  PROGRAM START *************************
'****************************************************

      Led = 0
      Xcs = 1
      Waitms 500

      'Hardware reset
      Xreset = 1
      Waitms 10
      Xreset = 0
      Waitms 10
      Xreset = 1
      Waitms 10

      Gosub Waitfordreq

      Waitms 10

      'write mode register (0), see sparkfun example
      Vs_write_spi &H00 , &H0C , &H20

      Gosub Waitfordreq

      'send test sequence
      'in the sparkfun example XCS is 1 here (inverted),
      'but both versions did not work
      Xcs = 0
      Waitus 5

      'send test sequence

      B = &H53
      H = Spi_transfer(b)
      Waitus 5

      B = &HEF
      H = Spi_transfer(b)
      Waitus 5

      B = &H6E
      H = Spi_transfer(b)
      Waitus 5

      B = 126
      H = Spi_transfer(b)
      Waitus 5

      B = &H00
      For I = 1 To 4
            H = Spi_transfer(b)
            Waitus 5
      Next I

      Xcs = 1
      Gosub Waitfordreq

      'End
      Do
            Toggle Ptest
      Loop

End


'###########################################################
Waitfordreq:
      Do
      Loop Until Dreq = 1
      Waitus 5
Return

'###########################################################
Function Spi_transfer(byval Spi_byte As Byte) As Byte
  Spdr = Spi_byte
  Do : Loop Until Spsr.spif = 1
  Spi_transfer = Spdr
End Function

'###########################################################

Sub Vs_write_spi(byval Vs_address As Byte , Byval Data1 As Byte , Byval Data2 As Byte)
Dim _h As Byte

  Xcs = 0
  B = Vs_wr
  _h = Spi_transfer(b)

  _h = Spi_transfer(vs_address)
  _h = Spi_transfer(data1)
  _h = Spi_transfer(data2)
  Xcs = 1
End Sub

_________________
Carsten,
with greetings from the nice city of Berlin
Back to top
View user's profile
papa_of_t

Bascom Member



Joined: 18 Jul 2005
Posts: 88

blank.gif
PostPosted: Tue Jun 06, 2006 10:29 am    Post subject: Reply with quote

Hi everybody!

I found the problem myself, there were multiple problems: First I misunderstood the XCS and did not respect that it must be high in shared mode to send data. Another problem was, that my power supply was nit stable enough, so finally i tricked myself, it is working and thank you for your help!

_________________
Carsten,
with greetings from the nice city of Berlin
Back to top
View user's profile
Kay

Bascom Member



Joined: 06 Jun 2006
Posts: 82

germany.gif
PostPosted: Wed Jun 07, 2006 8:25 pm    Post subject: Reply with quote

Hi,

i want to use the vs1002 without the sparkfun board. The Hardware is no problem. now the question :

How can i show the length of a track on a lcd ?

greetings Kay
Back to top
View user's profile
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    www.mcselec.com Forum Index -> BASCOM-AVR Archive All times are GMT + 1 Hour
Goto page Previous  1, 2
Page 2 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum