Search Forums by tag:
Serial, mbed, compiler, ethernet, USB, I2C, SPI, interrupt, LCD, library, bug, HTTPServer, CAN, AnalogIn, adc, Power, Ticker, memory, pwm, SD Card, InterruptIn, rpc, Error, SDFileSystem, PwmOut, LocalFileSystem, UART, canbus, driver, TCP, interrupts, rtos, led, libraries, editor, timer, accelerometer, GPS, file, clock, website, C++, SD, frequency, reset, http, LPC11U24, flash, SDCard, RTC, DigitalIn, TCPSocket, problem, printf, Java, Servo, buffer, UDP, SerialPC, DMA, HTTPClient, Sleep, audio, pinball, MODSERIAL, NetServices, socket, array, compile, filesystem, RFID, beta, m3pi, write, LPC1768, multiple, newbie, keyboard, sensor, GPRS, Forum, digitalOut, assembly, debug, hardware, Speed, xbee, AnalogOut, RPCFunction, EthernetNetIf, Download, code, voltage, wait, network, C, suggestion, JTAG, keil, MATLAB, offline, Board, lwip, I2S, dead, Nokia6610, time, bluetooth, WiFly, current, tcp/ip, MODDMA, SPI Slave, pololu, robot, Communication, read, dac, string, pc, binary, filter, copy, USB Host, publish, rs232, DHCP, Host, Data Logging, windows, firmware, malloc, mp3, PCB, gcc, attach, program, fatfilesystem, class, email, stepper motor, WavePlayer, wifi, Nokia, camera, size, VGA, import, documentation, ide, linux, baud, TextLCD, Cortex-M0, M0, pointers, pullup, Relay, timing, function, latency, serial port, MIDI, compiler error codes, magjack, touch, screen, Production, client, server, stream, HID, breakout, FIFO, prototype, flashing, GPIO, sampling, Analog, display, api, ADXL345, Encoder, DSP, help, motor, sram, suggestions, PING, Terminal, arduino, link, browser, Pin, control, Eagle, Modbus, EEPROM, mac, Timeout, fopen, port, updates, usbserial, batteries, DMX, files, USBMIDI, scanf, protocol, PPP, slave, FTP, integer, noise, MODGPS, modem, float, threads, motors, for, monitor, Digital I/O, 7, Windows Serial Driver, pins, keypad, FAT, classes, webserver, delay, variables, time-triggered, c programming, labview, watchdog, post, math, Battery, LPCXpresso, MBED website, GSM, storage, nxp, mobileLCD, license, int, counter, baseboard, Assembler, Vin, rj45, registers, E289, news, i2cmaster, amoled, Compiling, connect, revision, prototype to hardware, UMTSStick, Optocoupler, Robotics, search, oscillator, glitch, Websockets, load, find, real-time, routine, format, offline compile, powersource, driverlibrary, processing, networking, ID, umts, debugging, color, BUTTON, software, PS3, Images, wave, bin, const, SNMP, OSX, supply, peripheral, sensors, data, Design, PID, version, RIT, character, freeze, USBDevice, bus, ARM, wav, SRF08, heap, output, basic, TFT, QVGA, mysql, piezo, update, ID12, Pachube, player, DigitalInOut, object, cmsis, capture, slow, 1768, PSP, OS, syntax, mbed.lib, EmbeddedArtists, NMEA, paste, project, Web, GUI, UART0, firefox, SQL, wakeup, RAM, bitmap, handler, security, 3D, bugs, OLED, Temperature, not, I/O, Bidirectional, rss, wireless, delete, resolved, LED1, LIS302, getc, Safari, Wi-Fi, wiki, PinNames, accounts, PS2, BusOut, projects, RS485, pythonI don't know whether this works:
if(timerComplete & pulseCount < maxPulseCount )
But mabe this helps:
if(timerComplete && pulseCount < maxPulseCount )
Please log in to post a reply.
Hello,
I've been trying to create a repetitive pulsed output to the DAC using the MODDMA library.
I have found that when calling dma.Setup and dma.Enable or the equivalent Prepare function, the DMA call back does not always occur. (I have not tested the physical output so this may or may not be occurring every pulse).
The code below sets up the DMA configuration, attaches a timeout function "myhandler", enables the DMA transfer, and repeats this 1000 times. The PC serial connection, receives notification if the call back has occurred or not. Out of the 1000 times 971 call backs were made. This number changes with different timing parameters.
Please let me know if this is a DMA problem or I am just doing something fundamentally wrong.
Thanks, Jeff
Code
#include "mbed.h" #include "MODDMA.h" #define BUFFER_SIZE 100 Serial pc(USBTX, USBRX); DigitalOut led4(LED4); int buffer[BUFFER_SIZE]; AnalogOut signal(p18); MODDMA dma; MODDMA_Config *conf0, *conf1; void TC0_callback(void); void ERR0_callback(void); Timeout timeOutEMS; bool dmaTransferComplete = false; bool timerComplete = false; void myhandler() { pc.printf("timerComplete\r\n"); timerComplete = true; } int main() { signal = 0; pc.baud(115200); pc.printf("Hello World\r\n"); volatile int life_counter = 0; LPC_SC->PCLKSEL0 &= ~(3 << 22); // PCLK_DAC ck/4 (00) //CCLK = 96000000 Hz // fill buffer for use with DAC hardware. for (int i = 0; i < 100; i++) { buffer[i] = (0xFFFF & 0xFFC0); } // Prepare the GPDMA system for buffer0. conf0 = new MODDMA_Config; conf0 ->channelNum ( MODDMA::Channel_0 ) ->srcMemAddr ( (uint32_t) &buffer ) ->dstMemAddr ( MODDMA::DAC ) ->transferSize ( BUFFER_SIZE ) ->transferType ( MODDMA::m2p ) ->dstConn ( MODDMA::DAC ) ->attach_tc ( &TC0_callback ) ->attach_err ( &ERR0_callback ) ; // config end // Calculating the transfer frequency: // By default, the Mbed library sets the PCLK_DAC clock value // to 24MHz. LPC_DAC->DACCNTVAL = 24; // 1Msps timerComplete = true; int pulseCount = 0; int maxPulseCount = 1000; while (1) { if (life_counter++ > 10000000) { led4 = !led4; // Show some sort of life. life_counter = 0; } if(timerComplete & pulseCount < maxPulseCount ){ timerComplete = false; pc.printf("attach timer\r\n"); timeOutEMS.attach_us(&myhandler, 6000); wait_us(500); if (dma.Setup( conf0 )) { dma.Enable( conf0 ); if (pulseCount == 0) { // Begin (enable DMA and counter) LPC_DAC->DACCTRL |= (3UL << 2); } }else{ pc.printf("DMA Setup Error\r\n"); } wait_us(100); pulseCount++; } } } // Configuration callback on TC void TC0_callback(void) { signal = 0; // Just show sending buffer0 complete. pc.printf("TC0_callback\r\n"); // Get configuration pointer. MODDMA_Config *config = dma.getConfig(); // Finish the DMA cycle by shutting down the channel. dma.Disable( (MODDMA::CHANNELS)config->channelNum() ); // Tell main() while(1) loop to print the results. dmaTransferComplete = true; // Clear DMA IRQ flags. if (dma.irqType() == MODDMA::TcIrq) dma.clearTcIrq(); if (dma.irqType() == MODDMA::ErrIrq) dma.clearErrIrq(); } // Configuration callback on Error void ERR0_callback(void) { pc.printf("ERR0_callback\r\n"); }