Microphone 2 serial / DAT to PUB
TurboMan
Posts: 19
Sorry if this question is too simple. I'm new to the prop and have done a lot in BS2 and a little in SX assy. More hardware background then software.
With that said, here is my simple task. I have so many iterations of code I can't even pick one to put out here. I was using the microphone_to_headphone code and the FullDuplexSerialPlus code to simply pass microphone (78k sample) data out a serial port at 115200. At this point I just need to stream it out continually. I can decrease the sample rate but I need the baud rate. I've tried it a couple ways, each in their own cog and also tried a master cog grabbing data from microphone and then passing it off to the Serial port. I get data out but it's doesnt change. Probably my biggest confusion is the best way to get the microphone data from the assembly (DAT) out to the spin code. Can anyone simply tell me how to get the microphone data (from what I can understand it is the asm_sample that gets mov to frqb) into the FDSP code?
With that said, here is my simple task. I have so many iterations of code I can't even pick one to put out here. I was using the microphone_to_headphone code and the FullDuplexSerialPlus code to simply pass microphone (78k sample) data out a serial port at 115200. At this point I just need to stream it out continually. I can decrease the sample rate but I need the baud rate. I've tried it a couple ways, each in their own cog and also tried a master cog grabbing data from microphone and then passing it off to the Serial port. I get data out but it's doesnt change. Probably my biggest confusion is the best way to get the microphone data from the assembly (DAT) out to the spin code. Can anyone simply tell me how to get the microphone data (from what I can understand it is the asm_sample that gets mov to frqb) into the FDSP code?
Comments
Given these limitations, what do you want to do?
You are correct.. fat finger 7.8K I tried the standard bit setting of "13" which was 9.77khz and thought maybe it was too fast with overhead and then tried to fool the loop into grabing every 10th scan and sending it out(7.8k which was my roughly my scan target. 9.77k would be even better if it would work.) I know I can probably change the PLL setting of the clk but won't that change the operation of the whole Prop as opposed to a single cog? Anyway to get back to your question, in a nut shell... this is not for music only for basic audio. I would like to scan an 8 bit sample (I know low quality), grab it and send it out the serial port. I can't use hardware controls since the device I'm sending it to isn't using HW. I figured I would need to use a start stop bit. This process would be continual. The device at the other end will ignore the data until it gets an activation bit from another device and would then grab a 10 or 20 sec capture of audio and then go about it's business. I probably could do this with something else but thought it would be an opportunity to use the prop and I like the ability to expand other ideas into the project as I go along (other cogs just waiting to be used).
I hate to keep beating this dead horse but I still am having problems grabing data from another Cog. It sounds simple but I can't seem to get it. I can send data from one to another. In the microphone code the PUB line is as follows.
PUB StartAud (AudioSam)
cognew(@asm_entry, 0)
The Manual says that (AudioSam) would be a treated like a global variable ( thought that this would be a HUB Mem location). I'm trying to modify the HelloFullDuplexSerial prog to grab data from microphone and send it to FullDuplexSerialPlus. I can manually assign AudioSam to a bin num and it goes through to the terminal fine but I can't seem to grab it from Mic. How do I setup the Method to GET the data. Here is one of many attempts to GET the data????
CON
_clkmode = xtal1 + pll16x
_xinfreq = 5_000_000
OBJ
Audio: "microphone_gg"
SendSer: "FullDuplexSerialPlusGG"
PUB XferAudio2Ser | AudioSam, AudioOut
SendSer.start(31, 30, 0, 115200)
audio.startaud (@AudioSam)
repeat
SendSer.bin(AudioSam, 31)
SendSer.tx(13)
There are all sorts of examples of passing parameters from part of a program written in Spin to another part of the program written in assembly in its own cog. The "Getting Started and Key Thread Index" sticky thread here is a good starting place. Look at the assembly code examples and the machine language tutorial.
Thanks again for responding
Andy
Been putting out fires (I mean thermal incidents)lately and just getting back.
This is great code. I have something close to this but yours is cleaner(i'm still learning). I originally was trying to have 3 seperate cogs, 1 data handler, 2 adc, 3 serial but I think I'm changing my method(no pun intended). I'll experiment more using your cleaner code.
Thanks again!
Seems to work well and I will continue to add to this code.
Thanks