{"action":"created","issue":{"url":"https://api.github.com/repos/jonnew/cyclops/issues/5","repository_url":"https://api.github.com/repos/jonnew/cyclops","labels_url":"https://api.github.com/repos/jonnew/cyclops/issues/5/labels{/name}","comments_url":"https://api.github.com/repos/jonnew/cyclops/issues/5/comments","events_url":"https://api.github.com/repos/jonnew/cyclops/issues/5/events","html_url":"https://github.com/jonnew/cyclops/issues/5","id":146706969,"number":5,"title":"Porting Cyclops to Teensy [32b MCU]","user":{"login":"arrow-","id":9897445,"avatar_url":"https://avatars.githubusercontent.com/u/9897445?v=3","gravatar_id":"","url":"https://api.github.com/users/arrow-","html_url":"https://github.com/arrow-","followers_url":"https://api.github.com/users/arrow-/followers","following_url":"https://api.github.com/users/arrow-/following{/other_user}","gists_url":"https://api.github.com/users/arrow-/gists{/gist_id}","starred_url":"https://api.github.com/users/arrow-/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/arrow-/subscriptions","organizations_url":"https://api.github.com/users/arrow-/orgs","repos_url":"https://api.github.com/users/arrow-/repos","events_url":"https://api.github.com/users/arrow-/events{/privacy}","received_events_url":"https://api.github.com/users/arrow-/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/jonnew/cyclops/labels/enhancement","name":"enhancement","color":"84b6eb"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2016-04-07T18:28:25Z","updated_at":"2016-04-08T17:44:22Z","closed_at":null,"body":"[Teensy](http://www.pjrc.com/teensy/index.html) is a powerful microcontroller development system built on the ARM Cortex Mx architecture. It can be programmed via USB using the [Teensyduino]() plugin on the Arduino IDE or the TeensyLoader application. With more hardware timers and DMA, the Teensy could provide lower latency in waveform updation and many more features like signal measurement and larger waveform storage.\r\n\r\nFeature Comparison (with Arduino)\r\n-------------------------------------\r\nThe table [here](http://www.pjrc.com/teensy/teensyLC.html) (and [here](http://www.pjrc.com/teensy/teensy31.html)) from the Teensy main page summarises the major hardware features.\r\n>The Arduino Due has similar capabilities as the Teensy. They use the same Cortex M4 architecture but different manufacturer. Also, Due is programmed using the [`bossac`](http://shumatech.com/web/products/bossa) toolchain whereas Teensy is programmed using the `avr-gcc` toolchain like all ATmega based Arduinos.\r\n\r\n| Feature                 | Teensy LC                 | Teensy 3.2                       | Arduino Uno [8b] | Arduino Mega [32b] |\r\n| -----                   | ----                      | ---                       | ----             | ----               |\r\n| Processor               | Cortex-M0+ (MKL26Z64VFT4) | Cortex-M4 (MK20DX256VLH7) | Atmega328        | Atmega2560         |\r\n| Clock Speed             | 48MHz                     | 72MHz                     | 16MHz            | 16MHz              |\r\n| Flash Mem               | 62kB                      | 256kB                     | 32kB             | 256kB              |\r\n| SRAM                    | 8kB                       | 64kB                      | 2kB              | 8kB                |\r\n| EEPROM                  | ?                         | 2kB                       | 1kB              | 4kB                |\r\n| DMA channels            | 4                         | 16                        | 0                | 0                  |\r\n| ADC \"inputs\"            | 13                        | 21                        | 6                | 16                 |\r\n| DAC \"outputs\"           | 1                         | 1                         | 0                | 0                  |\r\n| Timers *(of all kinds)* | 7                         | 12                        | 2                | 5                  |\r\n| USART                   | 3                         | 3                         | 1                | 3                  |\r\n| SPI                     | 2                         | 1                         | 1                | 1                  |\r\n| I2C                     | 2                         | 2                         | 1                | 1                  |\r\n\r\nPorting Effort\r\n--------------\r\nTeensy uses the `avr-gcc` toolchain and allows user to run Arduino Sketches through the [Teensyduino](http://www.pjrc.com/teensy/teensyduino.html) plugin of Arduino IDE.\r\nThey have also [documented steps](http://www.pjrc.com/teensy/gcc.html) to utilise the `avr-gcc` toolchain directly *([baremetal Teensy development](http://www.seanet.com/~karllunt/bareteensy31.html))*, without using the Arduino headers.\r\nTeensyduino has a large collection of general purpose [libraries](http://www.pjrc.com/teensy/td_libs.html).\r\nThus, we can choose to cherry-pick libraries that work without Arduino headers or work with Arduino compatible librarires.\r\n\r\nTeensy References and Links\r\n----------------------------------\r\n[Teensy home page](http://www.pjrc.com/teensy/index.html)\r\n[TeensyLoader CLI](http://www.pjrc.com/teensy/loader_cli.html)\r\n[Teensy CPU datasheets](http://www.pjrc.com/teensy/datasheets.html), particularly the [K20 family](http://www.pjrc.com/teensy/K20P64M72SF1RM.pdf). All information on DMA was sourced from the `K20` datasheet."},"comment":{"url":"https://api.github.com/repos/jonnew/cyclops/issues/comments/207533471","html_url":"https://github.com/jonnew/cyclops/issues/5#issuecomment-207533471","issue_url":"https://api.github.com/repos/jonnew/cyclops/issues/5","id":207533471,"user":{"login":"jonnew","id":1429475,"avatar_url":"https://avatars.githubusercontent.com/u/1429475?v=3","gravatar_id":"","url":"https://api.github.com/users/jonnew","html_url":"https://github.com/jonnew","followers_url":"https://api.github.com/users/jonnew/followers","following_url":"https://api.github.com/users/jonnew/following{/other_user}","gists_url":"https://api.github.com/users/jonnew/gists{/gist_id}","starred_url":"https://api.github.com/users/jonnew/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jonnew/subscriptions","organizations_url":"https://api.github.com/users/jonnew/orgs","repos_url":"https://api.github.com/users/jonnew/repos","events_url":"https://api.github.com/users/jonnew/events{/privacy}","received_events_url":"https://api.github.com/users/jonnew/received_events","type":"User","site_admin":false},"created_at":"2016-04-08T17:44:22Z","updated_at":"2016-04-08T17:44:22Z","body":"Just a quick note that I received this and I'm processing it. Looks good,\nbut I need to think about it a bit before replying.\n\nOn Thu, Apr 7, 2016 at 2:36 PM, Ananya Bahadur <notifications@github.com>\nwrote:\n\n> Benefits to Cyclops\n>\n>    - Higher Clock Speed and 32b word size give a great performance boost.\n>    - There's a Native USB port and 3 other *(TTL)* Serial ports, allowing\n>    us to flash code while staying connected to other devices on (other) Serial\n>    ports.\n>    - A lot of special timers are available. These timers can be chained (\n>    *not* in arbitrary configurations) to perform sets of tasks without\n>    the intervention from the CPU.\n>       - *FlexTimers* are general purpose timers which can be triggered\n>       from other modules like ADC, etc. The FlexTimer interrupts can be used to\n>       trigger user code in an ISR or trigger other modules.\n>       - *Periodic Interrupt Timers* (PIT) can be set up to trigger\n>       modules like DMA (4 channels of DMA can be *periodically triggered*),\n>       etc.\n>       - *Programmable Delay Blocks* (PDB) can be set up to control ADC,\n>       DAC, comparator.\n>    - More digital I/O pins. And All I/O pins *can* be used as external\n>    interrupt pins on a Teensy. >I/O pins on Teensy 2.0, 3.1 and Teensy++ 2.0\n>    are 5V tolerant but on Teensy 3.2 and Teensy LC they are 3.3V tolerant.\n>    - Typical \"flashing\" of the Teensy requires pressing of a reset\n>    push-button. There is a guide\n>    <http://www.pjrc.com/teensy/jump_to_bootloader.html> that explains how\n>    to flash via a *software jump to bootloader*. This emulates \"pressing\n>    of the push-button\". >Hence, the GUI can be used to program the Teensy and\n>    there would be no need to run TeensyLoader or invoke a makefile before\n>    an experiment.\n>    - DMA can be used to write to almost any register on the CPU or\n>    peripherals without CPU intervention. DMA transfer_done interrupts can\n>    trigger other DMA transfers too!\n>\n> Setting up DMA for SPI\n>\n> With a Teensy, we might be able to expolit the DMA to regularly write to\n> the Cyclops DAC (via) SPI. This would free up the CPU to monitor the Serial\n> interface and do waveform updates. The pipeline *could* be:\n>\n> PIT -> DMA (2B transfer) to SPI `TXFIFO` -> `DMA_done` interrupt\n>\n> Since the CPU is free to perform updates, it would just wait for DMA-done,\n> after which it could update the contents of the DMA source for *\"this\"*\n> iteration. Next DMA-SPI event would be triggered by the *next* PIT\n> interrupt - maintaining a precise time-interval. The PIT periods can be\n> updated by the CPU anytime.\n>\n> A Teensyduino library for use of DMA with SPI (DmaSpi\n> <https://github.com/crteensy/DmaSpi>) is available. There is also a\n> chip-select option available, but the selection operation requires CPU\n> intervention.\n>\n> ------------------------------\n>\n> IMO *it might not be possible to perform a DAC transfer to the Cyclops\n> Driver without \"any\" intervention from CPU* in the way described. A\n> complete transfer not only requires the DAC value to be pushed into SPI\n> TXFIFO, but also\n>\n>    - selection of the DAC-slave-chip,\n>    - the actual SPI transfer and,\n>    - call to load_dac().\n>\n> The above described coordinated operations would require help from CPU. A\n> complicated pipeline might work but, just like a CPU, even DMA can get\n> overloaded.\n> *Moreover, since Teensy provides better clock speed, many hardware timers,\n> and more memory; the best way to deliver precise signals would be making\n> CPU handle all the waveform timing and SPI writes.*\n>\n> This would *in theory* increase latency (delay in waveform updates), but\n> compared to an Arduino, a Teensy runs 4 times faster anyway.\n> DMA can be utilised for other tasks *(see below)*.\n> Setup other USART ports as DATASTREAM\n>\n> Other USART ports can be used for streaming data *into* the Teensy or\n> streaming *out* to PC.\n> It might be possible to utilise the DMA triggers to do this operation\n> without CPU intervention.\n> Measuring and recording signals\n>\n> The Cyclops Driver,\n>\n> provides numerous measurements of circuit operation that can be recorded\n> during an experiment such as LED current and stimulus reference voltages.\n>\n> A PDB -> ADC -> DMA pipeline could be setup to record these analog signals\n> and store them on the Teensy or send them to PC in chunks. PDB would ensure\n> precise sampling intervals.\n> The chunk-send could also be be performed by the DMA over USART.\n>\n> —\n> You are receiving this because you are subscribed to this thread.\n> Reply to this email directly or view it on GitHub\n> <https://github.com/jonnew/cyclops/issues/5#issuecomment-207041463>\n>\n\n\n\n-- \nJonathan Newman\nPostdoctoral Fellow, MIT\nhttp://www.mit.edu/~jpnewman/\n"}}