Skip to content

Teensy 3.0 #1

Open
Open
@apmorton

Description

@apmorton

Hello,

I have spent some time making this work with teensy 3.0, but my efforts were mostly specific to my application, so I pretty much implemented only what I needed.

There are however some pointers I can give you from what I found.

It looks to me like what you do with pins_arduino_compile_time.h is already accomplished with the teensy 3.0, but I am not sure, so in my implementation I simply used digitalWrite for the latch pin. The clock speed is so much higher on the teensy 3.0 I don't think it matters much.

The most important part is of course the interrupt handler, which is mostly identical other than the add_one_pin_to_byte macro, which is as follows.

#define add_one_pin_to_byte(sendInt, thres, ptr) { \
    unsigned char val = *ptr; \
    asm volatile("cmp %0, %1" :: "r" (thres), "r" (val) :); \
    asm volatile("rrx %0, %1" : "=r" (sendInt) : "r" (sendInt) :); \
}

the ARM RRX function works on a 32bit register, so you must pass it an unsigned int for sendInt, and then shift it right 24bits after you add all the bits to send.

for the interrupt timer you use IntervalTimer

m_timer = new IntervalTimer();
period = 1000000.0 / (ledFrequency * maxBrightness);
m_timer.begin(myHandlerFunction, period);

with 3 registers at 100hz pwm frequency with 255 maximum brightness, these are my results.

Load of interrupt: 0.3640691
Clock cycles per interrupt: 685.31
Interrupt frequency: 25500.00 Hz
PWM frequency: 99.61 Hz

This is without the chips actually connected (by boards are being fabricated now), so I suspect much of that is waiting for SPI to timeout in the read loop?

If I don't actually send the values over SPI it drops to Load of interrupt: 0.1692283

If you would like to see my code I will gladly post it somewhere, but it is teensy 3.0 specific.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions