Author Topic: Teensy2.0 high pin voltage  (Read 1656 times)

0 Members and 1 Guest are viewing this topic.

Offline Eszett

  • Thread Starter
  • Posts: 543
  • Supporting the communities Geekhack & Deskthority
Teensy2.0 high pin voltage
« on: Sun, 20 September 2015, 18:59:47 »
Hi! I have a custom keyboard with Teensy2.0. When I measure the voltage of Teensy's input pins (which are pulled up) with my multimeter I always get 0.11v, how can that be? It should be about 5v, isnt it?

Offline fohat.digs

  • * Elevated Elder
  • Posts: 6471
  • Location: 35°55'N, 83°53'W
  • weird funny old guy
Re: Teensy2.0 high pin voltage
« Reply #1 on: Sun, 20 September 2015, 19:13:14 »
I am not an electrical engineer, by any means, but do you have any load on it?

Voltage available is not necessarily what is being pulled at the moment.
Citizens United violates the essence of what made America a great country in its political system. Now it’s just an oligarchy, with unlimited political bribery being the essence of getting the nominations for president or to elect the president.
So now we’ve just seen a complete subversion of our political system as a payoff to major contributors, who want and expect and sometimes get favors for themselves after the election’s over.”
- Jimmy Carter 2015

Offline Eszett

  • Thread Starter
  • Posts: 543
  • Supporting the communities Geekhack & Deskthority
Re: Teensy2.0 high pin voltage
« Reply #2 on: Sun, 20 September 2015, 19:26:08 »
Hi fohat! I just know some basics about microcontrollers. But AFAIK, when you set an input pin high, then it should have something close to VCC voltage, isn't it?

Offline ghostjuggernaut

  • * Curator
  • Posts: 3575
Re: Teensy2.0 high pin voltage
« Reply #3 on: Sun, 20 September 2015, 19:33:59 »
Are you measuring AC and not DC? Dumb question, I know, but we've all been there.

Offline Eszett

  • Thread Starter
  • Posts: 543
  • Supporting the communities Geekhack & Deskthority
Re: Teensy2.0 high pin voltage
« Reply #4 on: Sun, 20 September 2015, 19:52:17 »
I'm measuring DC, and between GND and VCC the multimeter shows correctly 5.15v.

Offline hasu

  • Posts: 3474
  • Location: Tokyo, Japan
  • @tmk
    • tmk keyboard firmware project
Re: Teensy2.0 high pin voltage
« Reply #5 on: Mon, 21 September 2015, 02:50:18 »
OK. I tested for you.
I guess your pin is mis-confgured(maybe as HiZ) with firmware or wiring is wrong somewhere.


VCC: 5.039V
Input (HiZ): 0.150-0.220V not stable
Input with Pull-Up: 5.020V
Output Low: 0.007V
Output Hi: 5.038V


I used this code with Teensy 2.0++.
Code: [Select]
#include <avr/io.h>
#include <avr/power.h>
#include <avr/wdt.h>
 
static void setup_mcu(void)
{
    /* Disable watchdog if enabled by bootloader/fuses */
    MCUSR &= ~(1 << WDRF);
    wdt_disable();
    /* Disable clock division */
    clock_prescale_set(clock_div_1);
}   
   
int main(void)
{   
    setup_mcu();
    //DDRB = 0x00; PORTB = 0x00;  // input(HiZ)
    DDRB = 0x00; PORTB = 0xFF;    // input with pull-up
    //DDRB = 0xFF; PORTB = 0x00;  // output Lo
    //DDRB = 0xFF; PORTB = 0xFF;    // output Hi
    while(1) ;
}


BTW, I prefer to discuss in the forum than IRC so that we can share info with and get more help from the community.  :thumb:

Offline Eszett

  • Thread Starter
  • Posts: 543
  • Supporting the communities Geekhack & Deskthority
Re: Teensy2.0 high pin voltage
« Reply #6 on: Mon, 21 September 2015, 17:26:11 »
Thanks, hasu, at least we know now, that 0.11v is bad. Here is the important part of my matrix.c, I think everything is correct there. What else can I do?

Quote
/* Column pin configuration
* col: 0   1   2   3   4   5   6   7   8   9   10  11  12  13  14  15  16
* pin: F4  B6  D1  D0  B7  E6  B3  B2  F0  B1  B0  D2  D3  C6  C7  D5  D4
*/
/* Row pin configuration
* row: 0   1   2   3   4
* pin: F7  F6  B5  F5  F1
*/

static void  init_cols(void)
{
    DDRF  &= (0<<4 | 0<<0);
    PORTF |= (1<<4 | 1<<0);
    DDRE  &= (0<<6);
    PORTE |= (1<<6);
    DDRD  &= (0<<5 | 0<<4 | 0<<3 | 0<<2 | 0<<1 | 0<<0);
    PORTD |= (1<<5 | 1<<4 | 1<<3 | 1<<2 | 1<<1 | 1<<0);
    DDRC  &= (0<<7 | 0<<6);
    PORTC |= (1<<7 | 1<<6);
    DDRB  &= (0<<7 | 0<<6 | 0<<3 | 0<<2 | 0<<1 | 0<<0);
    PORTB |= (1<<7 | 1<<6 | 1<<3 | 1<<2 | 1<<1 | 1<<0);
}


static matrix_row_t read_cols(void)
{
    return (PINF&(1<<4) ? 0 : (1UL<<0)) |
           (PINB&(1<<6) ? 0 : (1UL<<1)) |
           (PIND&(1<<1) ? 0 : (1UL<<2)) |
           (PIND&(1<<0) ? 0 : (1UL<<3)) |
           (PINB&(1<<7) ? 0 : (1UL<<4)) |
           (PINE&(1<<6) ? 0 : (1UL<<5)) |
           (PINB&(1<<3) ? 0 : (1UL<<6)) |
           (PINB&(1<<2) ? 0 : (1UL<<7)) |
           (PINF&(1<<0) ? 0 : (1UL<<) |
           (PINB&(1<<1) ? 0 : (1UL<<9)) |
           (PINB&(1<<0) ? 0 : (1UL<<10)) |
           (PIND&(1<<2) ? 0 : (1UL<<11)) |
           (PIND&(1<<3) ? 0 : (1UL<<12)) |
           (PINC&(1<<6) ? 0 : (1UL<<13)) |
           (PINC&(1<<7) ? 0 : (1UL<<14)) |
           (PIND&(1<<5) ? 0 : (1UL<<15)) |
           (PIND&(1<<4) ? 0 : (1UL<<16)) ;
}


static void unselect_rows(void)
{
    DDRF  &= 0b00011101;
    PORTF &= 0b00011101;
    DDRB  &= 0b11011111;
    PORTB &= 0b11011111;
}


static void select_row(uint8_t row)
{
    switch (row) {
        case 0:
         DDRF  |= (1<<7);        // "1<<.." = output (strobing)
         PORTF &= (0<<7);        // "0<<.." = LOW
            break;
        case 1:
         DDRF  |= (1<<6);        // "1<<.." = output (strobing)
         PORTF &= (0<<6);        // "0<<.." = LOW
            break;
        case 2:
         DDRB  |= (1<<5);        // "1<<.." = output (strobing)
         PORTB &= (0<<5);        // "0<<.." = LOW
            break;
        case 3:
         DDRF  |= (1<<5);        // "1<<.." = output (strobing)
         PORTF &= (0<<5);        // "0<<.." = LOW
             break;
        case 4:
         DDRF  |= (1<<1);        // "1<<.." = output (strobing)
         PORTF &= (0<<1);        // "0<<.." = LOW
            break;
    }
}



Offline Eszett

  • Thread Starter
  • Posts: 543
  • Supporting the communities Geekhack & Deskthority
Re: Teensy2.0 high pin voltage
« Reply #7 on: Mon, 21 September 2015, 17:50:31 »
Since about half an hour ago, there is no voltage anymore between GND and VCC. It happened without that I did anything. I did not mistreat the Teensy. I did not expose it to heat. The Teensy is not a fake from China. God in heaven, what has happened? :-((
« Last Edit: Mon, 21 September 2015, 17:53:45 by Eszett »

Offline hasu

  • Posts: 3474
  • Location: Tokyo, Japan
  • @tmk
    • tmk keyboard firmware project
Re: Teensy2.0 high pin voltage
« Reply #8 on: Mon, 21 September 2015, 19:33:57 »
Assuming you want to set those columns pins to 'input with pull-up' in init_cols(), your code may work with lucky situation but not correct basically.

You want to change only PF4 and PF0, but your code set all bits of DDRF to 0. Because (0<<4 | 0<<0) means just 0 and DDRF = DDRF & 0 = 0.
Quote
static void  init_cols(void)
{
    DDRF  &= (0<<4 | 0<<0);
    PORTF |= (1<<4 | 1<<0);


It should be like this. Note that (0<<4 | 0<<0) and ~(1<<4 | 1<<0) is totally diffrent meaning. ~(1<<4 | 1<<0) = 0b11101110 intead of 0.
Quote
DDRF  &= ~(1<<4 | 1<<0);                         
PORTF |=  (1<<4 | 1<<0);

Same things happen in select_row() too and I think your problem is there.
« Last Edit: Mon, 21 September 2015, 19:36:15 by hasu »

Offline Eszett

  • Thread Starter
  • Posts: 543
  • Supporting the communities Geekhack & Deskthority
Re: Teensy2.0 high pin voltage
« Reply #9 on: Mon, 21 September 2015, 22:01:36 »
I agree, that with changing the code I made a mistake. However, this is not related to my original problem, since the problem occured long before I changed the code. At the moment the Teensy doesn't like to work anymore, no voltage at all.

Offline Eszett

  • Thread Starter
  • Posts: 543
  • Supporting the communities Geekhack & Deskthority
Re: Teensy2.0 high pin voltage
« Reply #10 on: Tue, 22 September 2015, 01:55:38 »
One problem I've solved now. While debugging I plugged the USB cable in and out repeatedly and it's contacts became loose. The cable was the problem. Now I have voltage on the Teensy again  :) I uploaded the firmware with correct code now, as Hasu pointed out. However, the pins are still at 0.11v.