Serial comm with Maple

Serial comm with Maple

Postby chipaudette » Mon May 07, 2012 11:51 am

I've been using the Audio Codec Shield with an Arduino as a ADC and DAC for my PC for some lab work. I was streaming the data back to the PC over the Arduino's regular USB serial link. This worked fine but I decided that I wanted to do some real-time calculations on the Arduino and it didn't have enough horsepower...so I bought a Maple.

When I open up the Audio Codec Shield example program (sine_generator) from LeafLabs, the first thing that I see is that they disable the USBSerial saying that "conflicts with the codec".

Um, no serial? Really? That's a pretty big loss of functionality! It also makes debugging pretty hard. This also prevents me from using it as an ADC for my PC.

Are there any workarounds for this? The LeafLabs comment in the code also says that "a different operating mode which allows both is in the works". Has there been any progress?

Chip
chipaudette
 
Posts: 5
Joined: Fri Jan 27, 2012 8:14 am

Re: Serial comm with Maple

Postby chipaudette » Mon May 07, 2012 12:19 pm

Oh, and because the USBSerial is disabled in order to use the Codec Shield, you can't upload new code to the Maple from its IDE without putting the Maple into bootloader mode...which requires you to pull off the shield and press the magic combination of buttons.

This is quite a pain, it really slows me down, and it increases the likelihood bending pins on the shield.

Any knowledge or workarounds would be *greatly* appreciated!

Chip
chipaudette
 
Posts: 5
Joined: Fri Jan 27, 2012 8:14 am

Re: Serial comm with Maple

Postby guest » Tue May 08, 2012 1:15 pm

hello chip
sorry that i did not catch your first post

we havent recieved any updates from leaflabs
in regards to the USB problems
and youre right
it is quite a pain to have to reset on every upload

i will ask leaflabs to see if they can look at it
but if you want to post over at the leaflabs forums
there might be other users who have looked at this issue
guest
Site Admin
 
Posts: 449
Joined: Thu May 20, 2010 11:58 pm

Re: Serial comm with Maple

Postby guest » Tue May 08, 2012 1:25 pm

another thing to try
is to just comment out the usb code
and see what happens
if i recall correctly
the reason why it is there is because the usb makes audio glitches
but maybe it will be ok
guest
Site Admin
 
Posts: 449
Joined: Thu May 20, 2010 11:58 pm

Re: Serial comm with Maple

Postby guest » Wed May 16, 2012 10:51 pm

i was giving this some more thought today
and i think the problem with usb
is that it could only be blocked for so long
before it crashed the whole micro
and the interrupt routine for the codecshield
takes up all the processing time

one way around this
is to change what happens where
if only the first data transfer happened in the interrupt
and the rest happened in the main loop
it would block the usb
and usb would function fine
although this would cause the audio data
to not be transferred at exactly the right time
but im not sure how big of a problem that would be
guest
Site Admin
 
Posts: 449
Joined: Thu May 20, 2010 11:58 pm

Re: Serial comm with Maple

Postby vaxon » Tue Jun 12, 2012 5:43 pm

I'm not getting any real serial data back from the Arduinio. I tried stripping it down to :

ISR(TIMER1_COMPA_vect, ISR_NAKED) {
AudioCodec_data(&left_in, &right_in, left_out, right_out);
output=
reti();

With " Serial.println(out1);" in the loop and It just glitches out.

What was your test setup, chip?
vaxon
 
Posts: 4
Joined: Mon Jun 11, 2012 10:01 am

Re: Serial comm with Maple

Postby guest » Tue Jun 12, 2012 8:02 pm

the maple has different issues than the arduino

try changing the interrupt routine to:

ISR(TIMER1_COMPA_vect) {
}

this will have it push all the data onto the stack

the other thing to try
is to re-enable timer0
as the last line in your setup() put
TIMSK0 = 0x01;
guest
Site Admin
 
Posts: 449
Joined: Thu May 20, 2010 11:58 pm

Re: Serial comm with Maple

Postby guest » Wed Jun 13, 2012 11:12 pm

i just tried a number of variants
and i couldnt get the serial to talk
i will have to dig deeper to find out why
but i think the codec interrupt might be blocking for too long
or vice versa

i got it to transfer a few bytes
and it caused clicks when doing so

im working on a rewrite of the header file
that will allow for a different programming setup
and it might alleviate this problem

alternatively
a rewrite of the serial code would probably make it work
it depends upon what you want to do
streaming data out of the arduino would be pretty easy
just write UDR0 = byte;

ive got that working without any glitches

heres what you have to do:
1. change the interrupt routine to:
ISR(TIMER1_COMPA_vect) {

2. get rid of the reti; at the end of the interrupt routine
3. reinstate TIMER0 by writing TIMSK0 = 0x01 at the end of the setup routine
4. call Serial.begin() in the setup routine
5. call UDR0 = (byte of your data) when you want to send something

there isnt any flow control in this scheme
but delay() is now re-enabled
so you can just space it so it wont collide
guest
Site Admin
 
Posts: 449
Joined: Thu May 20, 2010 11:58 pm

Re: Serial comm with Maple

Postby clee » Fri Jul 06, 2012 4:43 am

It's my understanding that USB needs to be stopped when using the maple because the maple stm32 microcontroller is actually servicing the USB communication. libmaple does this using interrupts which glitch the audio processing. The arduino actually has a second microcontroller from FTDI just for USB input so that the main MCU doesn't have to worry about USB protocol servicing.

One option for you to get rapid serial communication is to use a FTDI breakout board or USB to serial cable and connect to one of the several serial interfaces on the maple. Lot's of manufacturers make these available (eg http://www.sparkfun.com/products/9718). I need to look again at the maple to see if it needs 5V or 3.3V serial input.

I think it is even possible to make it so the cable triggers a hardware reset of the maple---though I haven't done it myself.

I just got my audio codec shield so I might try this approach myself. I already have a few of these FTDI USB-to-serial gadgets.
clee
 
Posts: 7
Joined: Thu Jul 05, 2012 10:18 pm

Re: Serial comm with Maple

Postby guest » Fri Jul 06, 2012 5:05 pm

that sounds like a good idea
let us know how it goes

i think there will still be trouble with bootloading
as the bootload code wants to read from the onboard usb
guest
Site Admin
 
Posts: 449
Joined: Thu May 20, 2010 11:58 pm

Next

Return to Audio Codec Shield

Who is online

Users browsing this forum: Bing [Bot] and 1 guest


cron