SleepMode -> ATtiny85V

OP #6118077
Lesenswert?

Nabend,

ich bekomme es nicht hin, meinen Tiny aus dem Schlaf zu erwecken..
An "INT0" habe ich einen PullUp von ~10kOhm und einen Taster der den 
Pegel gegen GND zieht ( passt auch soweit! ).

Was mache ich falsch?

Die Pegeländerungen werden auch wunderbar von meinem Programm erkannt.
1
#include "../Includes/main.h"
2

3
void GoSleep( void )
4
{
5
    GIMSK |= _BV(INT0);                     // Enable Pin Change Interrupts
6
    ADCSRA &= ~_BV(ADEN);                   // ADC off
7
    set_sleep_mode(SLEEP_MODE_PWR_DOWN);    // replaces above statement
8
    sleep_enable();                         // Sets the Sleep Enable bit in the MCUCR Register (SE BIT)
9
    sei();                                  // Enable interrupts
10
    sleep_cpu();                            // sleep
11
    cli();                                  // Disable interrupts
12
    sleep_disable();                        // Clear SE bit
13
    ADCSRA |= _BV(ADEN);                    // ADC on
14
    sei();                                  // Enable interrupts
15
}
16

17
void ConfigInterrupt( void )
18
{
19
  GIMSK |= ( 1 << INT0 );
20
  MCUCR |= 1<<ISC00;
21
}
22

23
void Timer100us  ( void )
24
{
25
  if ( sTime.uiMilli++ > 9999 )
26
  {
27
    sTime.uiMilli = 0;
28
    sTime.uiSecound++;
29
  }
30
  
31
  if ( uiDebounce++ > 25 )
32
  {
33
    uiDebounce = 0;
34
    SwitchRead( &sKey );
35
  }
36
  
37
  
38
  static uint8_t uiPwmCnt = 0;
39
  if ( uiPwmCnt++ > 50 )
40
  {
41
    uiPwmCnt = 0;
42
  }
43
  
44
  if ( uiPwmCnt >= uiPwmLed[0] )
45
  {
46
    ShiftRegClearBit(0);
47
  }
48
  else
49
  {
50
    ShiftRegSetBit(0);
51
  }
52

53
  if ( uiPwmCnt >= uiPwmLed[1] )
54
  {
55
    ShiftRegClearBit(1);
56
  }
57
  else
58
  {
59
    ShiftRegSetBit(1);
60
  }
61
  
62
  if ( uiPwmCnt >= uiPwmLed[2] )
63
  {
64
    ShiftRegClearBit(2);
65
  }
66
  else
67
  {
68
    ShiftRegSetBit(2);
69
  }
70
  
71
  if ( uiPwmCnt >= uiPwmLed[3] )
72
  {
73
    ShiftRegClearBit(3);
74
  }
75
  else
76
  {
77
    ShiftRegSetBit(3);
78
  }
79
  
80
  if ( uiPwmCnt >= uiPwmLed[4] )
81
  {
82
    ShiftRegClearBit(4);
83
  }
84
  else
85
  {
86
    ShiftRegSetBit(4);
87
  }
88
  
89
  if ( uiPwmCnt >= uiPwmLed[5] )
90
  {
91
    ShiftRegClearBit(5);
92
  }
93
  else
94
  {
95
    ShiftRegSetBit(5);
96
  }
97
  
98
  if ( uiPwmCnt >= uiPwmLed[6] )
99
  {
100
    ShiftRegClearBit(6);
101
  }
102
  else
103
  {
104
    ShiftRegSetBit(6);
105
  }
106
  
107
  if ( uiPwmCnt >= uiPwmLed[7] )
108
  {
109
    ShiftRegClearBit(7);
110
  }
111
  else
112
  {
113
    ShiftRegSetBit(7);
114
  }  
115

116
  if ( uiPwmCnt >= uiPwmLed[8] )
117
  {
118
    ShiftRegClearBit(8);
119
  }
120
  else
121
  {
122
    ShiftRegSetBit(8);
123
  }
124

125
  ShiftRegUpdate();
126
}
127

128
ISR ( INT0_vect )
129
{  
130
  // nur zum aufwachen..
131
}
132

133
uint8_t uiMask = 0x01;
134

135
int main(void)
136
{  
137
   ShiftRegInit();
138
   
139
  SwitchInit( &sKey , &KEY_PORT , 1<<KEY_BP , 1<<KEY_BP , 1<<KEY_BP );
140
   
141
   Timer0CompAInit( &sTimer0OcieSettings[1] , Timer100us );
142
 
143
  ConfigInterrupt();
144
 
145
    while (1) 
146
    {     
147
    static uint8_t uiMode = 0;
148
    
149
    if ( SwitchGet( &sKey , 1<<KEY_BP ) )
150
    {
151
      if ( uiMode++ > 3 )
152
      {
153
        uiMode = 0;
154
      }
155
    }
156
    
157
    switch ( uiMode )
158
    {
159
      case 0:
160
          for ( uint8_t x = 0 ; x < 50 ; x++ )
161
          {
162
            uiPwmLed[0] = x;
163
            uiPwmLed[1] = x;
164
            uiPwmLed[2] = x;
165
            uiPwmLed[3] = x;
166
            uiPwmLed[4] = x;
167
            uiPwmLed[5] = x;
168
            uiPwmLed[6] = x;
169
            uiPwmLed[7] = x;
170
            _delay_us( 25 );
171
          }
172

173
          for ( uint8_t x = 0 ; x < 50 ; x++ )
174
          {
175
            uiPwmLed[0] = 50 - x;
176
            uiPwmLed[1] = 50 - x;
177
            uiPwmLed[2] = 50 - x;
178
            uiPwmLed[3] = 50 - x;
179
            uiPwmLed[4] = 50 - x;
180
            uiPwmLed[5] = 50 - x;
181
            uiPwmLed[6] = 50 - x;
182
            uiPwmLed[7] = 50 - x;
183
            _delay_us( 25 );
184
          }
185

186
      break;
187
      
188
      case 1:
189
          for ( uint8_t x = 0 ; x < 8 ; x++ )
190
          {
191
            uiPwmLed[x] = 50;
192
            _delay_us(25);
193
            uiPwmLed[x] = 0;
194
          }
195
      break;
196
      
197
      case 2:
198
        
199
          for ( uint8_t y = 0 ; y < 3 ; y++ )
200
          {
201
            for ( uint8_t x = 0 ; x < 8 ; x++ )
202
            {
203
              uiPwmLed[x] = 50;
204
            }
205
            
206
            _delay_us( 10 );
207
            
208
            for ( uint8_t x = 0 ; x < 8 ; x++ )
209
            {
210
              uiPwmLed[x] = 0;
211
            }
212
            
213
            _delay_us( 100 );
214
          }
215
          
216
          _delay_us( 1500 );
217
      
218
      break;
219
      
220
      case 3:
221
          uiMode = 0;
222
          //GoSleep();
223
      break;
224
    }
225
    }
226
}
Gast #6118101
Lesenswert?

Aus dem Datenblatt:

7.1.3 Power-down Mode
...
Only ... an external level interrupt on INT0 or a pin change interrupt 
can wake up the MCU.


Mit
MCUCR |= 1<<ISC00;
wird INT0 aber auf Flanke eingestellt. Also entweder INT0 auf 'low 
level' stellen oder PCINT verwenden.

Antwort schreiben

Bitte melde dich an, um einen Beitrag zu schreiben.

oder

Mit Google-Account einloggen

Die Registrierung ist kostenlos und dauert nur eine Minute.

Jetzt registrieren