This is ultimate Mikrobasic library, i tested it and it Work !!! thanks for your cooperation with Xmaspako.
=====================================================================
program WTV020TestXmaspako
' ResetPin=ra1 OUTPUT
' ClockPin=ra2 OUTPUT
' DataPin=ra3 OUTPUT
' BusyPin=RA4 INPUT
' connections between WTV020 and MCU
dim WTV020_RS as sbit at RA1_bit
WTV020_CL as sbit at RA2_bit
WTV020_DA as sbit at RA3_bit
WTV020_BS as sbit at RA4_bit
WTV020_RS_Direction as sbit at TRISA1_bit
WTV020_CL_Direction as sbit at TRISA2_bit
WTV020_DA_Direction as sbit at TRISA3_bit
WTV020_BS_Direction as sbit at TRISA4_bit
const _PLAY_PAUSE as word = $FFFE
const _STOP as word = $FFFF
const _VOLUME_MIN as word = $FFF0
const _VOLUME_MAX as word = $FFF7
' WTV020 initializas sbit ation
sub procedure Wtv020_Init()
ADCON0=0 'ATTIVA IL CONVERTITORE ANALOGICO DIGITALE
ANSEL=0 ' CONFIGURA TUTTI I PIN ANALOGICI COME DIGITALI
CMCON=0x07 ' SPEGNE IL COMPARATORE
'trisa=%00010001 ' Pone RA0 come Entrata,RA1..RA3 uscita,RA4 come Entrata
'trisb=%00000011 ' Pone RB0,RB1 come Entrata RB3..RB7 come Uscita
'setting up direction
WTV020_CL_Direction=0 ' set line as output
WTV020_DA_Direction=0 ' set line as output
WTV020_RS_Direction=0 ' set line as output
WTV020_BS_Direction=1 ' set line as input
WTV020_CL=0
WTV020_RS=1
'reset pulse
WTV020_RS=0
delay_ms(100)
WTV020_RS=1
'reset idle to start bit
WTV020_CL=1
delay_ms(300)
end Sub
'send command to module
sub procedure Wtv020_SendCommand(dim commando as word)
dim mask as byte
'clock low level pulse
WTV020_CL=0
'initial delay
delay_ms(2)
for mask=15 to 0 step -1
'clock timing
delay_us(50)
'transfer command bit to das sbit ata pin
if ((commando>>mask) and %0001>0) then
WTV020_DA=1
else
WTV020_DA=0
end if
'clock timing
delay_us(50)
'clock high level pulse
WTV020_CL=1
'clock timing
delay_us(50)
if (mask>0) then WTV020_DA=0 'set data pin to low (till last bit)
else WTV020_DA=1 end if
delay_us(50) 'clock timing
if (mask>0) then WTV020_CL=0 'clock low level pulse (till last bit)
else WTV020_CL=1 end if
next mask
'busy active high from last das sbit ata bit las sbit atch
delay_ms(20)
end sub
'play entire song and wait till song ends
sub procedure Wtv020_Play(dim voiceNumber as word)
Wtv020_SendCommand(voiceNumber)
'wait 20ms for busy to be active
delay_ms(20)
'do nothing and wait while BUSY is high
while(WTV020_BS)
wend
end sub
'start playing song and return
sub procedure Wtv020_AsyncPlay(dim voiceNumber as word)
Wtv020_SendCommand(voiceNumber)
end sub
'stop playing song
sub procedure Wtv020_Stop()
Wtv020_SendCommand(_STOP)
end sub
'pause/resume song
sub procedure Wtv020_Pause()
Wtv020_SendCommand(_PLAY_PAUSE)
end sub
'mute sound
sub procedure Wtv020_Mute()
Wtv020_SendCommand(_VOLUME_MIN)
end sub
'set volume (from 0 to 7)
sub procedure Wtv020_Volume(dim volume as byte)
if volume<8 then
Wtv020_SendCommand(_VOLUME_MIN+volume)
else
Wtv020_SendCommand(_VOLUME_MAX)
end if
end sub
'==========MAIN PROGRAM==========
'=======for test purposes========
'================================
main:
dim i as word
Wtv020_Init
'setting volume to half
Wtv020_Volume(4)
for i=0 to 5
Wtv020_AsyncPlay(i)
delay_ms(6000)
next i
'play second voice for 5 secs
'Wtv020_AsyncPlay(1)
'delay_ms(5000)
'pause play for 3 secs
'Wtv020_Pause()
'delay_ms(3000)
'setting volume to max
'Wtv020_Volume(7)
'resume play for 1 sec
'Wtv020_Pause()
'delay_ms(1000)
'Wtv020_Stop()
'play voice 0 till it ends
'Wtv020_Play(0)
end.
=========================================================================
Connect and program in microBasic to drive mp3 WTV020-SD-16P
General discussion on mikroElektronika website & forums.
Author
Message
Return to “Website & Forums General Discussion”
Jump to
- NECTO Studio
- ↳ IDE
- ↳ IDE General
- ↳ IDE Beta Testing
- ↳ IDE Wish List
- ↳ ARM AI Compilers
- ↳ mikroC AI for ARM
- ↳ mikroC AI for ARM General
- ↳ mikroC AI for ARM Beta Testing
- ↳ mikroC AI for ARM Wish List
- ↳ PIC AI compilers
- ↳ mikroC AI for PIC
- ↳ mikroC AI for PIC General
- ↳ mikroC AI for PIC Beta Testing
- ↳ mikroC AI for PIC Wish List
- ↳ PIC32 AI Compilers
- ↳ mikroC AI for PIC32
- ↳ mikroC AI for PIC32 General
- ↳ mikroC AI for PIC32 Beta Testing
- ↳ mikroC AI for PIC32 Wish List
- ↳ dsPIC AI Compilers
- ↳ mikroC AI for dsPIC
- ↳ mikroC AI for dsPIC General
- ↳ mikroC AI for dsPIC Beta Testing
- ↳ mikroC AI for dsPIC Wish List
- ↳ AVR AI Compilers
- ↳ mikroC AI for AVR
- ↳ mikroC AI for AVR General
- ↳ mikroC AI for AVR Beta Testing
- ↳ mikroC AI for AVR Wish List
- ↳ Additional Software
- ↳ Visual TFT AI
- ↳ Visual TFT AI General
- ↳ Visual TFT AI Beta Testing
- ↳ Visual TFT AI Wish List
- PRO Compilers
- ↳ PIC PRO Compilers
- ↳ PIC Compilers General
- ↳ mikroC PRO for PIC
- ↳ mikroC PRO for PIC General
- ↳ mikroC PRO for PIC Beta Testing
- ↳ mikroC PRO for PIC Wish List
- ↳ mikroBasic PRO compiler for PIC
- ↳ mikroBasic PRO for PIC General
- ↳ mikroBasic PRO for PIC Beta Testing
- ↳ mikroBasic PRO for PIC Wish List
- ↳ mikroPascal PRO for PIC
- ↳ mikroPascal PRO for PIC General
- ↳ mikroPascal PRO for PIC Beta Testing
- ↳ mikroPascal PRO for PIC Wish List
- ↳ dsPIC PRO Compilers
- ↳ dsPIC Compilers General
- ↳ mikroC PRO for dsPIC30/33 and PIC24
- ↳ mikroC PRO for dsPIC30/33 and PIC24 General
- ↳ mikroC PRO for dsPIC30/33 and PIC24 Beta Testing
- ↳ mikroC PRO for dsPIC30/33 and PIC24 Wish List
- ↳ mikroBasic PRO for dsPIC30/33 and PIC24
- ↳ mikroBasic PRO for dsPIC30/33 and PIC24 General
- ↳ mikroBasic PRO for dsPIC30/33 and PIC24 Beta Testing
- ↳ mikroBasic PRO for dsPIC30/33 and PIC24 Wish List
- ↳ mikroPascal PRO for dsPIC30/33 and PIC24
- ↳ mikroPascal PRO for dsPIC30/33 and PIC24 General
- ↳ mikroPascal PRO for dsPIC30/33 and PIC24 Beta Testing
- ↳ mikroPascal PRO for dsPIC30/33 and PIC24 Wish List
- ↳ PIC32 PRO Compilers
- ↳ PIC32 Compilers General
- ↳ mikroC PRO for PIC32
- ↳ mikroC PRO for PIC32 General
- ↳ mikroC PRO for PIC32 Beta Testing
- ↳ mikroC PRO for PIC32 Wish List
- ↳ mikroBasic PRO for PIC32
- ↳ mikroBasic PRO for PIC32 General
- ↳ mikroBasic PRO for PIC32 Beta Testing
- ↳ mikroBasic PRO for PIC32 Wish List
- ↳ mikroPascal PRO for PIC32
- ↳ mikroPascal PRO for PIC32 General
- ↳ mikroPascal PRO for PIC32 Beta Testing
- ↳ mikroPascal PRO for PIC32 Wish List
- ↳ AVR PRO Compilers
- ↳ AVR Compilers General
- ↳ mikroC PRO for AVR
- ↳ mikroC PRO for AVR General
- ↳ mikroC PRO for AVR Beta Testing
- ↳ mikroC PRO for AVR Wish List
- ↳ mikroBasic PRO compiler for AVR
- ↳ mikroBasic PRO for AVR General
- ↳ mikroBasic PRO for AVR Beta Testing
- ↳ mikroBasic PRO for AVR Wish List
- ↳ mikroPascal PRO for AVR
- ↳ mikroPascal PRO for AVR General
- ↳ mikroPascal PRO for AVR Beta Testing
- ↳ mikroPascal PRO for AVR Wish List
- ↳ FT90x PRO Compilers
- ↳ FT90x Compilers General
- ↳ mikroC PRO for FT90x
- ↳ mikroC PRO for FT90x General
- ↳ mikroC PRO for FT90x Beta Testing
- ↳ mikroC PRO for FT90x Wish List
- ↳ mikroBasic PRO compiler for FT90x
- ↳ mikroBasic PRO for FT90x General
- ↳ mikroBasic PRO for FT90x Beta Testing
- ↳ mikroBasic PRO for FT90x Wish List
- ↳ mikroPascal PRO for FT90x
- ↳ mikroPascal PRO for FT90x General
- ↳ mikroPascal PRO for FT90x Beta Testing
- ↳ mikroPascal PRO for FT90x Wish List
- ↳ 8051 PRO Compilers
- ↳ 8051 Compilers General
- ↳ mikroC PRO for 8051
- ↳ mikroC PRO for 8051 General
- ↳ mikroC PRO for 8051 Beta Testing
- ↳ mikroC PRO for 8051 Wish List
- ↳ mikroBasic PRO compiler for 8051
- ↳ mikroBasic PRO for 8051 General
- ↳ mikroBasic PRO for 8051 Beta Testing
- ↳ mikroBasic PRO for 8051 Wish List
- ↳ mikroPascal PRO for 8051
- ↳ mikroPascal PRO for 8051 General
- ↳ mikroPascal PRO for 8051 Beta Testing
- ↳ mikroPascal PRO for 8051 Wish List
- ↳ ARM PRO Compilers
- ↳ ARM Compilers General
- ↳ mikroC PRO for ARM
- ↳ mikroC PRO for ARM General
- ↳ mikroC PRO for ARM Beta Testing
- ↳ mikroC PRO for ARM Wish List
- ↳ mikroBasic PRO for ARM
- ↳ mikroBasic PRO for ARM General
- ↳ mikroBasic PRO for ARM Beta Testing
- ↳ mikroBasic PRO for ARM Wish List
- ↳ mikroPascal PRO for ARM
- ↳ mikroPascal PRO for ARM General
- ↳ mikroPascal PRO for ARM Beta Testing
- ↳ mikroPascal PRO for ARM Wish List
- ↳ Older versions of Compilers
- ↳ Older versions of mikroC Compilers
- ↳ mikroC for PIC
- ↳ mikroC General
- ↳ mikroC Beta Testing
- ↳ mikroC Wish List
- ↳ mikroC for dsPIC30/33 and PIC24
- ↳ mikroC for dsPIC30/33 and PIC24 General
- ↳ mikroC for dsPIC30/33 and PIC24 Beta Testing
- ↳ mikroC for dsPIC30/33 and PIC24 Wish List
- ↳ RSC-4x mikroC
- ↳ RSC-4x mikroC General
- ↳ RSC-4x mikroC Wish List
- ↳ mikroC Beta testing
- ↳ Older versions of mikroBasic Compilers
- ↳ mikroBasic compiler for PIC
- ↳ mikroBasic General
- ↳ mikroBasic Beta Testing
- ↳ mikroBasic Wish List
- ↳ mikroBasic compiler for dsPIC30/33 and PIC24
- ↳ mikroBasic for dsPIC30/33 and PIC24 General
- ↳ mikroBasic for dsPIC30/33 and PIC24 Beta Testing
- ↳ mikroBasic for dsPIC30/33 and PIC24 Wish List
- ↳ mikroBasic for dsPIC30/33 and PIC24 Bug List
- ↳ Obsolete Project: mikroBasic compiler for AVR
- ↳ mikroBasic for AVR General
- ↳ mikroBasic for AVR Wish List
- ↳ mikroBasic Beta testing
- ↳ Older versions of mikroPascal Compilers
- ↳ mikroPascal compiler for PIC
- ↳ mikroPascal FAQ
- ↳ mikroPascal General
- ↳ mikroPascal Beta Testing
- ↳ mikroPascal Wish List
- ↳ mikroPascal Bug List
- ↳ mikroPascal compiler for dsPIC30/33 and PIC24
- ↳ mikroPascal for dsPIC30/33 and PIC24 General
- ↳ mikroPascal for dsPIC30/33 and PIC24 Beta Testing
- ↳ mikroPascal for dsPIC30/33 and PIC24 Wish List
- ↳ mikroPascal for dsPIC30/33 and PIC24 Bug List
- ↳ Obsolete Project: mikroPascal compiler for AVR
- ↳ mikroPascal for AVR General
- ↳ mikroPascal for AVR Wish List
- ↳ mikroPascal Beta testing
- ↳ Library Development Discussion
- ↳ Code Requests
- Additional Software
- ↳ Visual TFT Software
- ↳ Visual TFT General
- ↳ Visual TFT Beta Testing
- ↳ Visual TFT Wish List
- ↳ Visual GLCD Software
- ↳ Visual GLCD General
- ↳ Visual GLCD Beta Testing
- ↳ Visual GLCD Wish List
- ↳ Package Manager Software
- ↳ Package Manager General
- ↳ Package Manager Beta Testing
- ↳ Package Manager Wishlist
- ↳ GLCD Font Creator Software
- ↳ SpeakUp Software
- ↳ Timer Calculator
- ↳ CAN Calculator
- ↳ mikroBootloader
- Hardware
- ↳ Development Boards
- ↳ CODEGRIP programmer and debugger
- ↳ Mikromedia
- ↳ mikroProg™ programmer and debugger
- ↳ Development Boards Wishlist
- ↳ Review
- ↳ Click Boards release
- ↳ Hexiwear
- Website & Forums
- ↳ Libstock Discussion
- ↳ Product Announcements
- ↳ Website & Forums General Discussion
- ↳ Website & Forums Wishlist
- ↳ User Projects