Please Help "Soft_Uart Transmission Program"

General discussion on mikroC.
Post Reply
Author
Message
antony1925
Posts: 18
Joined: 20 Nov 2011 08:54

Please Help "Soft_Uart Transmission Program"

#1 Post by antony1925 » 21 Nov 2011 10:28

Hello People,

I am trying to send some test characters when a reed switch is taken as an interrupt on RB0.
Basically, when the reed switch circuit is closed the RB0 pin is interrupted and the program should wake up the ISR and send the test character.

The problem I am facing is, while checking in the oscilloscope the reed switch is interrupting but the program is not executing the ISR. I can see the transition if the switch from high to low but the ISR does not respond. I have also written the code in the software that the interrupt is on a falling edge because the reed switch goes low when the switch is closed.

I have attached the code.

Code: Select all

unsigned char cnt = 0;
void main()
{
PORTB = 0;
//CMCON 0x07;
Soft_Uart_INIT(PORTC,7,6,57600,0);
delay_ms(500);
INTCON = 0b10010010;
INTCON2 = 0b00000001;
while(1)
{}
}
void interrupt()
{
if(INTCON.INT0IF == 1)
{
Soft_Uart_write(3);
}
INTCON.T0IF = 0;
}
Please help me find a solution.

Best Regards
Antony

balazs
Posts: 37
Joined: 20 Mar 2010 14:53

Re: Please Help "Soft_Uart Transmission Program"

#2 Post by balazs » 23 Nov 2011 09:51

Hello,
please set your port as input with TRISH. If its port B then TRISHB = 1;
and correct your code to this:

Code: Select all

void interrupt()
{
if(INTCON.INT0IF == 1)
{
INTCON.INT0IF=0;
Soft_Uart_write(3);
}
}
Best regards,
Balazs

antony1925
Posts: 18
Joined: 20 Nov 2011 08:54

Re: Please Help "Soft_Uart Transmission Program"

#3 Post by antony1925 » 23 Nov 2011 11:14

Hi,

Thanks for your help!!

I will surely try that!

Cheers!

Post Reply

Return to “mikroC General”