![]() | ![]() | ![]() |
| |||||||
| Micro Controllers Discuss all aspects of micro controllers - building them, coding them, etc. All controllers are welcome - PIC, BASIC, Z8 Encore!, etc. |
![]() |
| | Tools |
| | #1 |
|
helllllllllo eveybody i have this project where the use of ps2 mouse is required and i am having real problem interfacing it to the micro, i am using the 16f877a. the clock of the ps/2 is pulled high by a pull-up resistor and connected to the external interrupt pin B0. the data pin is connected to pin D2 and also pulled high now i am able to monitor the signal using the pickit2, when the mouse is powered up it sends 0xAA 0x00 bytes, i am able to confirm that. here is the img ![]() the problem is when i try read the signal using the microcontroller i faild, even when simply just trying to count the clock pulses at PIN B0 during mouse power up Code:
#int_EXT
void EXT_isr(void)
{
pulses++;
}
.
.
.
void main()
{
pulses = 0;
.
.......PIC initialization code.........
.
ext_int_edge( H_TO_L ); //track high to low transitions on pin
enable_interrupts(INT_EXT);// enable external interrupt
enable_interrupts(GLOBAL);
set_tris_b(0xff);
while(true)
{
printf("pulses: %u\r\n",pulses);
delay_ms(500);
}
}
pulses: 1 where it should be 22 i belive here is what i tried to do : - remove the pickit2 while the pic is doing its job trying to count them pulses - remove the pullup resistors - enable/disable portb weak pull ups - re-enable the ext_int at the ISR - simulating with protues isis gives correct result !!! i dont know whats wrong + ive been trying to solve it for 2 days so any suggestions are highly appreciated !! thanks for reading. | |
| |
| | #2 |
|
Post all your code instead of where you think the problem is. A few questions/suggestions, is the wdt turned off, how and where is pulses defined, which compiler are you using. Mike. | |
| |
| | #3 |
|
ok this the code Code: #include <16F877A.h>
#device adc=8
#FUSES NOWDT //No Watch Dog Timer
#FUSES HS //High speed Osc (> 4mhz)
#FUSES NOPUT //No Power Up Timer
#FUSES NOPROTECT //Code not protected from reading
#FUSES NODEBUG //No Debug mode for ICD
#FUSES NOBROWNOUT //No brownout reset
#FUSES NOLVP //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O
#FUSES NOCPD //No EE protection
#FUSES NOWRT //Program memory not write protected
#use delay(clock=20000000)
#use rs232(baud=57600,parity=N,xmit=PIN_C6,rcv=PIN_C7,bits=8)
#use fast_io (B)
volatile unsigned int x;
#int_EXT
void EXT_isr(void)
{
disable_interrupts(INT_EXT);
x++;
clear_interrupt(INT_EXT);
enable_interrupts(INT_EXT);
}
void main()
{
x =0;
setup_adc_ports(NO_ANALOGS);
setup_adc(ADC_OFF);
setup_psp(PSP_DISABLED);
setup_spi(SPI_SS_DISABLED);
setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);
setup_timer_1(T1_DISABLED);
setup_timer_2(T2_DISABLED,0,1);
setup_comparator(NC_NC_NC_NC);
setup_vref(FALSE);
enable_interrupts(INT_EXT);
enable_interrupts(GLOBAL);
port_b_pullups (false);
while(1)
{
printf("%u\r\n",x);
delay_ms(1000);
}
}
| |
| |
|
| Tags |
| external, interrupt, pic, problem, ps or 2 |
| Thread Tools | |
| Display Modes | |
| |
Similar | ||||
| Title | Starter | Forum | Replies | Latest |
| PIC 16F877 external Interrupt Problem!!! | mesamune80 | Micro Controllers | 6 | 24th June 2008 02:18 AM |
| RB0 External Interrupt Problem | Suraj143 | Micro Controllers | 6 | 30th August 2007 07:26 AM |
| how to handle external interrupt | anch | Micro Controllers | 1 | 3rd June 2006 03:21 AM |
| external interrupt | neelam29 | Micro Controllers | 4 | 11th March 2006 02:50 PM |
| external interrupt address | neelam29 | Micro Controllers | 4 | 25th February 2006 03:00 AM |