Search Engine

62 Threads found on Portb Interrupt
The exercise problem doesn't mention interrupts, I won't use it here. The processor is doing nothing that must be interrupted, it can just wait for key presses in a loop. If you prefer it though, portb change interrupt might be an option.
Here is mikroC PRO AVR Code. It uses Timer to get 1 second delay. LEDs are connected to portb. char count = 0; //Timer1 Prescaler = 64; Preload = 31249; Actual interrupt Time = 500 ms //Place/Copy this part in declaration section void InitTimer1() { SREG_I_bit = 1; TCCR1A = 0x80; TCCR1B = 0x0B; OCR1AH =
i am trying to make 2 push button interrupt and to calculate the time elapsed between them using counter t and make the result displayed on port c the problem is that portb rb4 is interrupting automatically i donot why there is my codeint x=0; int t=0; void interrupt(){ if(INTCON.F1){ x = portb; (...)
hello if(INTCONbits.INT0IF == 1){ Trigger_Sensor(); INTCONbits.INT0IF = 0; } in your interrupt treatment, you have RB0 interrupt wich do "Trigger_Sensor();" is pin RB0 used ? if not , remove it.. remove also INTCONbits.GIE = 1; INTCONbits.PEIE = 1; variable temp1 = portbbits.RB4;
It's on portb. 1.) Run init function to setup global interrupts 2.) Write interrupt
You are not telling it to put the result back in portb. from the data sheet: ADDWF Add W and f Syntax: ADDWF f,d Operands: 0 ≤ f ≤ 127 d ∈ Operation: (W) + (f) → (destination) Status Affected: C, DC, Z Description: Add the contents of the W register with register ?f?. If ?d? is ?0?, the
unsigned char x; // interrupt Handler void interrupt() { // RB Port Change interrupt if(PIR1.RBIF == 1) // if the RB Port Change interrupt flag is set... { PORTA.F1 = ~PORTA.F1;//LED on/off on press of switch x = portb; // Need to read or write to the port to clear mismatch (...)
You can connect the TSOP as shown in the tsop datasheet (Image attached) and portb interrupt on change function can be used to detect the pulse. refer the attachments for more 95909
I don't think there are PICS with more than one INT pin. Still most of them have Interrpt on change for portb pins. You can also use CCP modules in the PIC to capture events. As a last resort you can use a 3 input AND gate to tie the three interrupts to the one INT pin of the PIC. Hope this helps :) PS : 16F877A is a midrange PIC with lots of per
hi, i have posted the code ,please can anyone tell me what is the problem in generating the pwm output int freq,rpm,prpm,k; interrupt service routine { k++ portb=0x02; } input capture service routine int crpm=tcnt1; freq=tcnt1; if(tov1) { rpm=((tov1*65535)/freq)+((crpm-prpm)/freq); } else { rpm=((crpm-prpm)/freq); }
Hi, Your simulation will not run until your tie the chips pin 1 to VDD direct or via a pull up resistor 10k. As Rog232 says you can use portb input interrupt functions, but how are you wanting to read the input PWM pulses and how are you wanting to output them on the second pic, directly controlled port pulses or via a PWM module. The latter
Try with this code: unsigned int adc_val; unsigned char FlagReg; sbit Turn at FlagReg.B0; void checkMode() { if (RA2_bit == 0) { portb = 0b00000010; } else { portb = 0b00000100; } } void driveLED(unsigned int adc_val) { if (adc_val >= 0 && adc_val <= 40) { PORTD = 0b00000000; POR
Thr interrupt on these pins occur on change. have you read datasheet properly. read datasheet and read about portb mismatch i had used this interrupt to interface keypad and it works fine - - - Updated - - - Thr interrupt on these pins occur on change. have you read datasheet properly. read datasheet and read about p
Hi, In a word, yes it would be possible, however you will need to go though your lcd routine as they often change RB0 from input to output along with the other portb pins. You need to have RB0 totally free of the lcd routine and any TRIS instruction it may use. You need to show the lcd code you are using. On a 40 pin chip like that its ge
this is my full code,,,am using Hi-Tech C compiler... void main() { TRISD=0x00; PORTD=0x00; TRISB=0x00; portb=0x00; TRISE=0x01; PORTE=0x01; lcd_init(); uart_init(); value=200; lcd_string(data); lcd_cmd(0x88); __delay_ms(30); while(1) { lcd_cmd(0x88); __delay_ms(30); if(sw==1) { __delay_m
Use this: char channB = 0; int num = 0; void interrupt (void) //incomplete type is not allowed { if(RBIF_bit == 1) { num++; channB = portb; RBIF_bit = 0; } } You don't need to write isr for the ISR. Just use void interrupt(void){ } When writing/reading bits, you must write _bit at the end. RBIF is
Thank you for your replay. This is the circuit which I used. In the code I wrote, when a interrupt in the INT0 pin, where zero crossing detector is connected, portb.0 become High that mean it trigger the TRIAC. after 1000uS later it become turn off. In this case light become less brightly, around 45voltage AC can be found across the light. But if t
Hi Paradigm; If your proc has PORT Change interrupt (at least on 4 pins like almost all PICs on portb) and it can wake-up from SLEEP (see your datasheet) then it is possible using only one interrupt (this). For example set all 4 keypad columns to zero and pull up (as usual) the rows to VCC. If the 4 rows are connected to the 4 input (...)
Four of the portb pins (RB7:RB4) have an interrupt on change feature. Int0, Int1, Int2 on pins RB0, RB1, RB2. Thats 7 external interrupts
Hi, Just taking your question as you ask, then using the portb interrupt on Change feature of Rb4 -7 would seem one obvious way. However you do not give any exact details of the coin mechanism, to show its logic or electrical details; can you post its datasheet ? Have you written any code so far ? it helps if you show it. Are you just
Hall Sensor Based BLDC Motor driving using microcontroller. .... void interrupt isr() { if(RBIF) { RBIF=0; hall_sens=(portb&0Xe0); // HALL EFFECT SENSOR READING .... Hi; There are some minor programming mistake in the code, but it still works, as we see.
i configured portb change interrupt BSF INTCON, GIE BSF INTCON, RBIE BCF OPTION_REG,RBPU so i simulated with Proteus. when I enable the pullup, it automatically interrupt without press the button Hi; It is due the wrong order. First set the used portb pin(s) as input via TRISB then clear RBPU to en
Use the portb interrupt-on-change for counting number of buttons pushed and to start counting when a button is pushed and until released. For counting number of clock pulses, use the RB0/INT pin. In the interrupt vector, check which interrupt occurred. Hope this helps. Tahmid.
Maybe it is operator precedence? Try using brackets. if(RBIF == 1) { if(!(portb & (1 << BUTTON))) // Use more brckets! { sportb ^= (1<
This code does quite well in receiving serial data and operating the relay drive ports, which have a command for setting and unsetting. my problem is when then stepper motor attached to portb is set in motion, I cannot operate anything else unless I turn off the power to reset. I am sure its an interrupt thing, but I do not know where to start wi
In your second ISR routine you must first read portb to clear the "mismatch condition" and THEN you can clear RBIF. See the PIC's datasheet ...
Hi, I do not code in C, but there seems 2 obvious problems with your code. First see the datasheet i/0 ports section, you need to make portb Digital instead of the default Analogue. Second, you seem to be enabling 2 differenet types of Interrrupt, RBIE is for the change on RB4-7, INT0IE is for RB0.
Use External interrupt (portb) to count the coin pulse. when you insert a coin you will get interrupt and use counter with it. void interrupt() { if(INT0IF_bit) { // Rising Edge INT0IF_bit = 0; counter++; }
Just go for interrupt method in portb pins in case of PIC micro. Y you want to always power the rows and columns?
Hi Guys, i have googled and searched but the 16F887 seems to be harder to get working then a 18F4550.. can someone please point out the obvious mistake im making in the below? im only working with the 16F887 as i have run out of 18F4550's... any help would save my sanity greatly!!!! ;*************************************************
you cant use Both at same time. Use CCP module to capture the IR code. portb interrupt will not give you exact values. It will give you timing of Low and High level of IR signal received by HS0038B . it is best for IR decoding.
just a suggestion... If you are using PIC, can't you use EXT INTR on portb; it has interrupt on change facility. May be it can work. ---------- Post added at 07:52 ---------- Previous post was at 07:51 ---------- when ISR gets called; use a static variable to store the data.
Yes, you can use an external interrupt on the PIC18F. USING THE PIC EXTERNAL interrupt AN566 Using the portb interrupt on Change as an External
I think portb also the function for AD converter. By default portb is AD inputs. You should need to set portb as Digital function mode first then define as input. Check ADCON register. Hope helps
Hello, Try using LATB instead of portb for your output pin definitions this should help. Flowcode has a built in component to handle servo motors.
hiii, i use portb external interrupt for pic16f84a and when interrupt end i want the pic start from new lable like this "interrupt code" main: code . . . out: code . . . end. i want when interrupt end start from out: lable code
ok are you using CCP module or portb change interrupt?
hi: my simulator object is Atmega8 and my code below: #include #define __enable_interrupt() SREG |= 0X80; #define __disable_interrupt() SREG &= 0X7F; #pragma vector= TIMER0_OVF_vect //timer overflow function, name doesn't matter. __interrupt void timer_overflow(void) { //LED toggle portb ^= (...)
you could use a timer to generate interrupts (say at 20KHz) incrementing 4 counters. you could then poll or use portb input change interrupt looking for a change of state of the sensors. When a change occurs the corresponding counter would give you the number of timer interrupts since the previous change hence the period
Why shouldn't this code work? #include void main (void) { TRISA = 0x00; TRISB = 0x00; PORTA = 0x00; portb = 0x00; OPTION = 0x07; RBPU = 0; T0IE = 1; INTEDG = 1; GIE = 0; while(1) CLRWDT(); } static void interrupt ISR() { if(T0IF && T0IE) { T0IF = 0; PORTA = ~PORTA; } }[/
int Counter=0; void interrupt() { INTCON=0x20; //Clear the GIE and the T0IE TMR0=0; //Re-initialize TMR0 register ++Counter; //Increment the dummy variable } void main() { TrisB=0; //Configure portb as Output TrisA=255; //C
firstly, do your program needs something more? or it's just detect input pulse and then bang! output on portb... so to rearm the system just a reset? does it will have some user interface? (lcd,keypad) if not, you can use the PIC INTs inputs, and "wake" from a Sleep() with no more business...(no watchdog no other interrupt) even, yo don't ne
Hello.Refering to my previous e-mail,finally I convert the assembly language example firmware, that is;(EXAMPLE 4/ page 4 of AN566 application note; ) into C language and I attached it and AN566 pdf with this mail.But would you please anybody answer to the following questions my helpi
Hi! everybody.I want to write a program with mikroC PRO V2.5 so that I can use the interrupt on change portb; RB4,RB5,RB6,RB7 features.I use 4 push buttons on pins; RB4(K4),RB5(K5),RB6(K6),RB7(K7) and 4 LEDs' on pins;(respectively) RC4(LED1),RC5(LED2),RC6(LED3),RC7(LED4);I want if each key pressed(K4 to k7) the corresponding pins(LED)
Hi, You can achieve this a couple of different ways. First you can add into your delay routine so that it checks the status of the stop timing switch every 250ms or so, btfss portb,0 Second you can use the interrupt on Change feature of Port B - as detailed in the I/O portb section of the datasheet.
Hi adalah, I guess, you never leave this while ---------------------------------------------------------- void servo1pos3(void) { OPTION_REG = 0b10000000; // Assign prescaler to TMR0 TRISB = 0; // portb is output portb = 0XFF; // Initialize portb INTCON = 0xA0; // Enable TMRO interrupt cnt = 0; // Initialize (...)
Hello I have been studying different parts of a program in the simulator and on project board. I ran into something I don't understand. I'll post the code then explain the problem ;Timer1-s1.asm FOR SIMULATOR ; program to test timer1 LIST p=16F628a ;tell assembler what chip we are using include ""
Hello, It seems my sleeping PIC18 cannot wakeup at interrupts via button switches on portb. It only wakes at at reset on teh RESET pin. Any idea how to wakeup the sleeping PIC18 at interrupt (hi to lo transition) at portb, pin 0. Thanks, neo
how can i read 50Hz with PIC. i am using pic basic plus but i cant use pulsin command for this purpose bcaz i my main loop i cant wait so long. can i read 50Hz square wave through interrupts if i use portb.0 for the hardware interrupt, i cant use CCP pin for capture purpose bcaz i am generating PWM with this pin. i am using 16f73 with xtal (...)