/
Kód: Vybrať všetko
*
* Project name:
External Interrupt on PortD (Simple 'Hello World' project)
* Copyright:
(c) Mikroelektronika, 2010.
* Revision History:
20101006:
- initial release;
- 20101006 - Ranko Rankovic;
* Description:
This is a simple 'Hello World' project. It counts presses on PortD.3 and
shows result on diodes connected to PORTB.
* Test configuration:
MCU: ATmega16
http://www.atmel.com/dyn/resources/prod_documents/doc2466.pdf
Dev.Board: EasyAVR6
http://www.mikroe.com/en/tools/easyavr6/
Oscillator: External Clock 08.0000 MHz
Ext. Modules: -
SW: mikroC PRO for AVR v4.10
http://www.mikroe.com/en/compilers/mikroc/avr/
* NOTES:
- Make sure you turn ON the PORTB LEDs (SW8.2), set PortD Pull Up Jumper in Vcc position (J4)
and turn on PortD.3 Switch (SW4.4)
*/
int cnt = 0; // Global variable cnt
void interrupt_ISR () org IVT_ADDR_INT1 { // Interrupt rutine
SREG_I_bit = 0; // Disable Interrupts
cnt++; // Increment variable cnt
SREG_I_bit = 1; // Enable Interrupts
}
void main() { // Main program
DDRD = 0xF7; // Set PD3 as input
DDRB = 0xFF; // Set PortB as output
PortD = 0x00;
PortB = 0xFF; // Starting value for PortD
GICR = 0b10000000; // Set the Interrupts
MCUCR = 0b00001000; // Configure Interrupt for falling edge on PortD.3
SREG_I_bit = 1; // Enable Interrupts
while(1){ // Unending loop
PortB = cnt; // Write on PortB value of varibale cnt
}
}
Poz.: čo som ja používal mincovníky, tak ani jeden nemal na výstupe žiadne zákmity, výstup bol buď logická úroveň, alebo otvorený kolektor.