![]() |
Forum Index : Microcontroller and PC projects : MMBasic and SPI Interface
Author | Message | ||||
boris007 Newbie ![]() Joined: 16/06/2020 Location: AustraliaPosts: 5 |
Hi Everyone. I am trying to interface to a VS1011 MP3 IC. I am using the PIC32MX470 on a board that works - but i am stuck with getting SPI to do what i need it to. The VS1011 datasheet asks to write 4 bits (hex values) to the VS1011. Here is what they say:- - write 4 bytes , 0x2, 0xB, 0x0, 0x0 - then cycle a few pins and then send 0x2, 0xB, 0xFF, 0xFF I have tried numerous combinations but i must be missing something simple. Can anyone please shed light on where i am going wrong? Here is a part of the MMBasic code i am trying:- (i converted the hex values to decimal) do pin(29)=0 SPI WRITE 1,2 SPI WRITE 1,11 SPI WRITE 1,0 SPI WRITE 1,0 pin(29)=1 pause 500 pin(29)=0 SPI WRITE 1,2 SPI WRITE 1,11 SPI WRITE 1,255 SPI WRITE 1,255 pin(29)=1 pause 500 pin(29)=1 loop I would appreciate any wise guidance Thanks Alan |
||||
TassyJim![]() Guru ![]() Joined: 07/08/2011 Location: AustraliaPosts: 6283 |
What do you have for SPI OPEN It is hard to diagnose with only part of the story! Jim VK7JH MMedit |
||||
boris007 Newbie ![]() Joined: 16/06/2020 Location: AustraliaPosts: 5 |
My Apologies - here is the full code. I know the PIC32MX470 is working as i use the module to control other circuits. But i just can't get the VS1011 to respond like it should. When the hex codes are sent, i should be able to hear some "slight popping" on the sound out on the VS1011 module. But i hear nothing. There is another test i have ran and that does not work either. I am obviously making a pigs ear of using SPI even though i have it working in other programmes any wise suggestion would be really appreciated Option autorun on TROff SetPin 28, din 'DREQ SetPin 29, dout 'xCS SetPin 30, dout 'xDCS pin(29)=1 'xCS =1 ie not selected pin(30)=1 'xDCS =1 ie not selected SPI open 1000000, 3, 8 do pin(29)=0 SPI WRITE 1,2 SPI WRITE 1,11 SPI WRITE 1,0 SPI WRITE 1,0 pin(29)=1 pause 500 pin(29)=0 SPI WRITE 1,2 SPI WRITE 1,11 SPI WRITE 1,255 SPI WRITE 1,255 pin(29)=1 pause 500 pin(29)=1 loop |
||||
Volhout Guru ![]() Joined: 05/03/2018 Location: NetherlandsPosts: 5089 |
Hi Boris, Not sure, but I expect the SPI mode should be mode 1 (active clock is HIGH). ![]() If you are using MMBasic on an MX470 processor, are you running MMBasic 4.5? In the MMBasic 4.5 manual I have not found SPI OPEN. Every configuration is done in the SPI command itself. I must be confused... PicomiteVGA PETSCII ROBOTS |
||||
matherp Guru ![]() Joined: 11/12/2012 Location: United KingdomPosts: 10310 |
MX470 is the Micromite Plus which runs the latest version of MMbasic. The original Mono/Colour Maximite is the MX695/MX795 which only has MMbasic 4.5 |
||||
TassyJim![]() Guru ![]() Joined: 07/08/2011 Location: AustraliaPosts: 6283 |
As well as trying mode 1, I would try sending all 4 bytes in th eone command SPI WRITE 4,2,11,0,0 VK7JH MMedit |
||||
Grogster![]() Admin Group ![]() Joined: 31/12/2012 Location: New ZealandPosts: 9610 |
@ Boris07 - you are opening the SPI at 1MHz. Is that correct? The SPI clock might simply be way to fast for the device. Does the device specify a 1MHz SPI clock? Most SPI things I have talked to, have a much slower clock then 1MHz, with the exception of SD-cards and LCD's. I would not expect an MP3 player module to need a clock that fast, but I could well be wrong. Smoke makes things work. When the smoke gets out, it stops! |
||||
Mixtel90![]() Guru ![]() Joined: 05/10/2019 Location: United KingdomPosts: 7937 |
VC1011e data sheet is Here - That's quite some chip! I trust you aren't using VS1001 compatibility mode, Alan? XDCS is SPI CS SCK is clock SI is connected to MOSI / SPI OUT on the PIC SO is connected to MISO / SPI IN on the PIC I suspect you might need to run SPI in Mode 1. SPI frequency should not be higher than CLK1/7. Better a bit lower so probably no higher than about 3MHz as the minimum internal clock (CLK1) is 24MHz. Mick Zilog Inside! nascom.info for Nascom & Gemini Preliminary MMBasic docs & my PCB designs |
||||
boris007 Newbie ![]() Joined: 16/06/2020 Location: AustraliaPosts: 5 |
Hi Guys Thanks for the help - really appreciated. Looks like the comments provided really helped me as i was able to initiate the sine wave test from the VS1011 module. As suggested, i slowed the clock down, changed to mode 1 ie SPI OPEN 30000,1,8 Can probably go higher with clock, but this is fine for testing. Once i did this, i could enter the data as hex or decimal and i was able to hear the sine wave. I was also also able to send the data in one lump, or line by line. Now that this portion shows i can write to the registers correctly, i now need to understand more about the VS1011. The datasheet examples don't work as proposed but i believe the problem is with me and not the datasheet. If anyone has successfully connected the Sparkfun MP3 Module with VS1011e to a micromite, I would appreciate any pointers or help! Thanks everyone - you made my day |
||||
![]() |
![]() |
The Back Shed's forum code is written, and hosted, in Australia. | © JAQ Software 2025 |