Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
10 years, 11 months ago.
DAC MCP4821 and NXP 11U24 : How to increase frequency of output
I have been using MCP4821 for a while now , I have managed to get it to correctly output a signal , but after rigorous tweaking and analysis I ve only managed to take it from 15 hz to 1 khz of frequency . Is this the limit ? Does anybody know a way to increase my output to say 20 mhz ?
2 Answers
10 years, 11 months ago.
The SPI lib should be able to go to pretty high frequencies for SCK, but toggling the CS line using the DigitalOut method may be a limiting factor on the relatively slow 11U24. DMA could improve the update speed. Could you publish your code to see what else may be done.
10 years, 11 months ago.
You will got nowhere near 20MHz. That simply is way outside the abilities of the LPC11u24 to send (or hell any device to send using SPI), and outside the capabilities of the MCP4821.
That said, it should be do-able to get alot faster than 1kHz, so like Wim said, could you show your code.
test.cpp
The LPC11u24 can't get higher than 24MHz (your DAC also not, so that's not an issue. Also while I like people using my libraries, in this case BurstSPI doesn't make it go faster: BurstSPI is intended for situations where ALOT is written without toggling CS. For example a regular LCD writes 153kB without raising/lowering its CS pin. Writing one word and then waiting until it is done with that won't be faster than using regular SPI.
There are some options to make it go faster. But most important two questions:
When you say 15Hz-1kHz, do you mean the speed it outputs values, or the time it takes to finish a complete period of your triangle wave. Question 2: What are your requirements. So we can judge if they are realistic on the LPC11u24.
posted by Erik - 21 Dec 2013Firstly when I say 15hz-1khz I mean the actual output of the signal when measured with an osciloscope . And second my requirements are to take it to at least 10 khz as I will be also reading and analysing some signals at the same time having this one at a greater frequency can ensure that it won't become extremely slow when I add the extra functionality . Also I would like to ask , is there any chance 11u24 can support multi-threading ? or not . If not how about its big bro NXP 1768??
posted by Antreas Antoniou 21 Dec 2013Well the easiest option to increase your speed is to make your ramps using larger steps, now you add 0x0F for each step, increasing that makes it go faster.
With multi-threading, you can look at the RTOS (search for it here), it allows you to have several threads which all do their own thing. However there is still only one physical core, so it will not be able to actually do several things in parallel. Same for the LPC1768. There are some multi-core microcontrollers, for example from NXP one with an M0 core in parallel to an M4 core, but generally that isn't really required, or you simply put two microcontrollers in parallel.
posted by Erik - 21 Dec 2013Yes , thats exactly why I have 0x000f so that I increase the speed from the original 0x0001 stepping . Thanks for your input . Already found multi threading technique . Also if there is any other option to increase speed other than stepping please don't hesitate to share. Thanks once more
posted by Antreas Antoniou 21 Dec 2013The SPI module can also toggle a pin as CS pin automatically. I am not sure that pin is available on the LPC11u24, but for sure it would mean you need to do some manual writing to registers. If you are comfortable with that you can look in the user manual which registers you need for that.
posted by Erik - 21 Dec 2013