Archives
-
Disabling interrupt in code vision avr
i tried to use interrupt INT0 of atmega16..
i wnt to disable interrupt once the program enters the INTERRUPT SUBROUTINE and enable the interrupt once the ISR gets over. but for the interruot to start for thr first time #asm(“sei”) needs to be given in the main()..
i want to enavle interrut once and then disable it in the ISR..
i have given my code below.
plz help..interrupt [EXT_INT0] void ext_int0_isr(void)
{
#asm(“cli”);
delay_ms(4.752);for(i=0;ilt11;i++)
{
PORTC=PINDampamp0x04;
PORTA=0×00;
delay_us(864);
PORTA=0×01;
delay_us(864);
}
PORTA=0×00;
delay_us(864);
PORTA=0×02;
delay_us(864);
PORTA=0×00;
}void main(void)
{
PORTA=0×00;
DDRA=0xFF;PORTB=0×00;
DDRB=0×00;PORTC=0×00;
DDRC=0xFF;PORTD=0×00;
DDRD=0×00;#asm(“sei”);
while (1)
{
// Place your code here};
}
Related Forum Messages
- Decoding rc5 tv remote
- Again PORTS on ATMEGA16
- Interrupt handling using pic16f877a
- ATMega8535 + Servo motors
- Newbie interrupt problem
- “How much time/clock needed to execute this (if) comman
- Wierd behaviour with Atmega16
- Hi-Tech C Compiler: What am I doing wrong?
- Weird behaviour of AtMega16
- Pin Change Interrupt and Pin Change Interrupt Flag!!
- [SOLVED] Not able to move vehicle and servo
- PIC16F690 Hi tech C Interrupt problems
- Mega32 MMC ff.h f_open exit
- Basic Input out
- Anyone familiar with ADS1252 from TI?
- Having trouble getting ISRs to work
- Help Reading PIN State
- A simple question about this program
- Port A.5 A.4 A.3 don’ work on PIC16F677
- Bitbangging UART Problem
i tried to decode phillips tv remote IR signal using atmega16 and TSOP 1738(ir reciever) 1st i used interrupts(INT0 - pin16th) to detect the 1st falling edge to syncronise the delays..but after it goes to the interrupt subroutine the falling edges in the input datastream is also considered as interrupt and the subroutine is repeated. suggest me some help to overcome this problem. can i use polling as an alternative to interrupts? if so how? please help. i am using code vision avr as my programming tool.. i am givvin my code: interrupt [EXT_INT0] void ext_int0_isr(void) { #asm("cli"); delay_ms(4.752); for(i=0;ilt11;i++) ...Since I didn't got any answer on my previous question I reopen the item. I am using an ATMEGA16 with internal 8 MHz clock, and am trying to toggle PORTA.0 but seen with an oscilloscope nothing happens, what could be the problem? Code: #include ltmega16.hgt void main(void) { PORTA=0x00; DDRA=0xFF; PORTB=0x00; DDRB=0xFF; PORTC=0x00; DDRC=0xFF; PORTD=0x00; DDRD=0xFF; while (1) { PORTA.0 = 1; PORTA.0 = 0; };Hi Tahmid, I am using mickoC and proteus for simulation. Please tell me some advices regarding the problem of this code. This code is for our traffic light project and I've got a problem with the push button(which is the interrupt), it won't work. Code: int j=5; int i=0; int count = 0; void interrupt(void) { for(i=0;i<5;i++) { PORTA = 0xFF; ...Hi guys, i have ATMega8535 microprocessor and 2pcs of Servo motors that im going to try to make prototype of robotic arm, the servo motors that i have is Hitec HS-422 deluxe. Servo use +5~6 Vdc. when i test the servo motors, it's not working, i dont know if it's the servo's having trouble or i made the wrong programm. the program list i made is like this : Code: #include ltmega8535.hgt #include ltdelay.hgt int i; PORTA=0x00; DDRA=0xFF; PORTB=0x00; DDRB=0x00; PORTC=0x00; DDRC=0x00; PORTD=0x00; DDRD=0x00; while (1) { // Place ...I'm really struggling to understand the interrupts. I could use some help please! My code is simple (below). What I want is to make a short pulse on PORTA.1 that is triggered by Trigger5ms(); and reset by the interrupt handler. Why doesn't this work? What am I missing? It seems I've tried everything! BTW, Im using EasyPIC5 and mikroC pro. Thanks, Doug --------- code ------------ unsigned int a = 0; unsigned short dd = 0; void interrupt() { if (PORTA != 0) { PORTA = 0; } else { PORTA = 1; } //INTCON.GIE = 0; INTCON.TMR0IE = 0; // disable TMR0 interrupt INTCON.TMR0IF = 0; // reset TMR0 interrupt flag - get ready for a new ...hi guys, i have some questions here: Code: /***************************************************** This program was produced by the CodeWizardAVR V2.04.4a Advanced Chip type : ATmega8535 Program type : Application AVR Core Clock frequency: 12.000000 MHz Memory model : Small External RAM size : 0 Data Stack size : 128 *****************************************************/ #include ltmega8535.hgt unsigned int a=0; unsigned int b=10000; unsigned long int c=0; unsigned int delay=0; unsigned int delay1=0; // External Interrupt 0 service routine interrupt [EXT_INT0] void ext_int0_isr(void) { // Place your code here a=b; b=0; } // Timer1 overflow interrupt service routine interrupt [TIM1_OVF] void timer1_ovf_isr(void) { // Reinitialize Timer1 value TCNT1H=0xFF; TCNT1L=0xDC; ...Hi Every1.. I had made a line follower with 3 sensors , and the fourth signal given to the PIN of PORTA3 to give the start signal.. But this is not executing.. The robot remains in the while loop forever may be plz help.. In Avr studio debug mode its goin as i thought it shud but is wierd with the chip..Plz help\ Code: #define F_CPU 1000000UL #define del 15 #include ltavr/io.hgt #include ltutil/delay.hgt int main(void) { DDRA = 0xFF; PORTA = 0x00; DDRD = 0x00; PORTD = 0xFF; ...I am trying to program a PIC16F877A. I know my hardware is good because I can load on the LED blink program from here: blink a LED and it works. I am trying to do an led blink program using the Hi-Tech C Compiler. I have it specified as the tool chain in MPLab. Here is my code: #include ltpic.hgt #include ltconio.hgt #include ltstdlib.hgt #include ltstdio.hgt #include ltctype.hgt #include "delay.h" //#include "delay.c" //void delay(void); //#define _16F877 // __CONFIG(UNPROTECT|BODEN|FOSC1|BKBUG|WRT); //__CONFIG( XT amp WDTDIS amp PWRTDIS amp BORDIS amp LVPDIS amp WRTEN amp DEBUGDIS amp UNPROTECT ); void main (){ ADCON1 =0x06 ; // Changes PORTA to digital CMCON = 0x07 ; // Disable analog comparators PORTA = 0x00 ...Hi, I have made a line follower using Atmega16. I am using L293D motor driver.I have connected 12V to the Vs of this IC. I am getting weird behavior from uc. But when I am connecting the Vs to 5V, I am getting perfect behavior. P.S. I am using PortA pins 0-3 for connecting output to motor driver. I am using PortD pins for input. Here is the code also for reference: Code: #define F_CPU 1000000UL #define del 20 #include ltavr/io.hgt #include ltutil/delay.hgt int main(void) { DDRA = 0xFF; PORTA = 0x00; ...I'm using an ATMEGA324P at 8Mhz. I want to use one switch (SW2) for turn on LEDS connected to PortA an other switch (SW3)to turn on LEDs connected to PortC. SW2 with pin change interrupts and sw3 with external interrupt, but i dont want the microcontroller interrupts when you push the switch, the main program must detect when a switch has been pressed detecting when PCIF1 enable or INTF0 enable. But SW2 dont turn on the LEDS. SW1 works OK. What could be wrong?? This is the code and the schematic is add as attachment: //******************INCLUDE FILES******************* #include ltavr/io.hgt #include ...I want to move a vehicle as well as move a servo in between....but the simulator does not give desired result.....PLS Check the code below I am Using MIKROC Code: void main() { TRISC=0x00; TRISB=0xFF; ADCON1=0x06; CMCON=0x07; TRISA=0XFF; TRISD=0X00; PORTB=0x00; PORTC=0X00; while(1) { while(PORTB==0x20) { PORTD=0x30; } while(PORTB==0x40) { PORTD=0x20; } while(PORTB==0x10) { PORTD=0x10; } while(PORTB==0x80) { PORTD=0xC0; } while(PORTB==0x00) { PORTD=0x00; } if(RA0) { PORTC=0x04; Delay_us(2000); PORTC=0x00; Delay_us(18000); } if(RA1 && RA0) { PORTC=0x04; Delay_us(1350); PORTC=0x00; Delay_us(18650); } if(RA1) { PORTC=0x04; Delay_us(2000); PORTC=0x00; Delay_us(18000); } } } Thanks In ADVANCEHi, i am trying to get a external interrupt working in the PIC16F690, the code seems to be ok, but when i try simulating the program in the mplab sim it just jumps straight to the ISR holds there for a while and then jumps to the infinite loop. i am using Hi tech C compiler, and trying to just toggle the PORTB on the external interrupt, but a am at a loss as to why its not working . . . . any help will be greatly appreciated Code : #include <htc.h> #include "delay.h" //------------------------------------ void main(void) @0x00 { //Initialisation TRISA=0xFF; TRISB=0x00; TRISC=0x00; PORTA=0xFF; PORTB=0x00; PORTC=0x00; ANSEL=0x00; ANSELH=0x00; WPUB=0x00; GIE=1; INTEDG=1; PEIE=1; INTE=1; while(1) { ...hello i use fatfs module to use mmc by atmega32 =gt http://elm-chan.org/fsw/ff/00index_e.html i wrote this code in codevision Code: #include ltmega32.hgt #include ltff.hgt #include ltstdio.hgt #include ltdelay.hgt #define T1_OVF_FREQ 100 #define T1_PRESC 1024L #define T1_INIT (0x10000L-(_MCU_CLOCK_FREQUENCY_/(T1_PRESC*T1_OVF_FREQ))) FRESULT res; FATFS fat; FIL file; char path[]="0:/ECA.txt"; interrupt [TIM1_OVF] void timer_comp_isr(void) { /* re-initialize Timer1 */ TCNT1H=T1_INITgtgt8; TCNT1L=T1_INITamp0xFF; /* card access low level timing function */ disk_timerproc(); } void main(void) { PORTA=0x00; DDRA=0xFF; PORTB=0x00; DDRB=0x00; PORTC=0x00; DDRC=0xFF; PORTD=0x00; DDRD=0x00; TCCR1A=0x00; TCCR1B=(1ltltCS12)|(1ltltCS10); TCNT1H=T1_INITgtgt8; TCNT1L=T1_INITamp0xFF; TIMSK=1ltltTOIE1; ...I am having trouble with the simple application on the STK 600 demo board. I want to pressed a switch on board to select a Case. Please help me out in the right direction. Code: int main(void) { DDRA = 0xFF; // portA as output DDRD = 0x00; // portD as input DDRB = 0xFF; PORTB = 0xF0; while (1) { ...Hi there I am a newbie who is very lost in programming this adc. I am using AVR162 but any experience and advice on how to work with this sort of adc is very much appreciated. I have tried all possible ways that I can think of to make it work but still.. I am lost.. and desperate. These are few codes that I attempted. Code: #include ltavr/io.hgt #include ltavr/interrupt.hgt #include ltutil/delay.hgt #define F_CPU 1000000UL volatile unsigned char RDY_FLG= 0x00; volatile unsigned char SCLK_FLG = 0x00; // sclk flag long char data = 0; int k; void init (void) { ...I'm not sure if I should post here, or in a Hi-Tech forum, so I apologize in advance. I'm trying to get a simple ISR going. I first wanted to interrupt when pin RA5 transistioned from low to high, but when I couldn't get that to work, I figured I'd try a slam dunk thing like TMR0. Well, I didn't get either to work... [:@] Here's my code: #include <htc.h> void main() { // RA0 and RA1 are analog inputs //TRISA = 0x23; ...im totally new to this world, i got 16F877A, and tried to mod the LEDs example provided with mikroC but Failed to Read PORTA.RA0 State Code: Select all void main() { ANSEL = 0; // Configure AN pins as digital ANSELH = 0; C1ON_bit = 0; // Disable comparators C2ON_bit = 0; TRISA = 0xFF; // set direction to be input TRISB = 0x00; ...hi every one this program is belong to a project whit AVR (( atmega16)) and is written to controll a DC motor whit this microcontroller. i had a question about this code (( that is written in C language)) and i want you to do me a favour and answer this question here is the program: Code: #include <mega16.h> // Alphanumeric LCD Module functions #asm .equ __lcd_port=0x1B ;PORTA #endasm #include <lcd.h> #include<delay.h> void display_no(int no); void direction(char dir); void main(void) { // Input/Output Ports initialization // Port A initialization PORTA=0x00; DDRA=0x00; // Port B initialization PORTB=0x00; DDRB=0x08; // Port C initialization PORTC=0x00; DDRC=0x00; // Port D initialization PORTD=0x00; DDRD=0xFF; // Timer/Counter 0 initialization TCCR0=0x6A; TCNT0=0x00; OCR0=0x00; // Timer/Counter 1 ...Hello I'm trying hello word project on PIC16F677, all port work good less that A.5 A.4 and A.3 Why?? Code: Select all void main() { ANSEL = 0; // Ingressi analogici disattivati ANSELH = 0; C1ON_bit = 0; // comparatori disattivati C2ON_bit = 0; TRISA = 0x00; // PortA = output TRISB = 0x00; ...Hi world! Iam writing code to perform bit bangging. Iam testing my code on proteous. Scheme of code is that iam Recieveing data using INT0 (Interrupt 0). I have configured INT0 on falling edge and using the Virtual Terminal in Proteous iam sending data at baud rate of about 4800. i have written the following code. Code: // *********************************************************** // Project: // Author: // Module description: // *********************************************************** #include ltavr\io.hgt #include ltavr\interrupt.hgt #include ltavr\signal.hgt #include ltutil\delay.hgt unsigned char value = 0x00; unsigned int bitcount = 1; unsigned int i = 0; #define en 0x04 #define ew 0x02 ...
