CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

Frequency Interrupt

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
aaronik19



Joined: 25 Apr 2011
Posts: 297

View user's profile Send private message

Frequency Interrupt
PostPosted: Mon Mar 11, 2013 8:34 am     Reply with quote

I am in a middle of a project and currently I am facing a problem with the interrupt Service Routine ISR. I made some test code below:

Code:

#include <frequency.h>
#define LCD_ENABLE_PIN PIN_A1
#define LCD_RS_PIN PIN_A3
#define LCD_RW_PIN PIN_A2
#define LCD_DATA4 PIN_D4
#define LCD_DATA5 PIN_D5
#define LCD_DATA6 PIN_D6
#define LCD_DATA7 PIN_D7

#include <lcd1.c>


int zc_count, period_read = 0;

#int_TIMER1
void  TIMER1_isr(void)
{

}

#int_TIMER2
void  TIMER2_isr(void)
{

}

#int_TIMER3
void  TIMER3_isr(void)
{

}

#int_EXT
void  EXT_isr(void)
{
  zc_count++;
  if (zc_count == 3)
  {
   period_read = get_timer1();
   set_timer1(0);
   zc_count = 0;
  }

}

#int_EXT1
void  EXT1_isr(void)
{

}

void setup()
{
   set_tris_a(0x00);
   set_tris_b(0x01);
   set_tris_c(0xff);
   set_tris_d(0x00);
   set_tris_e(0x00);
   output_a(0x00);
   output_b(0xfd);
   output_c(0x00);
   output_d(0x00);
   output_e(0x00);
   setup_timer_1(T1_INTERNAL|T1_DIV_BY_8);      //104 ms overflow
   setup_timer_3(T3_DISABLED|T3_DIV_BY_1);
   enable_interrupts(INT_TIMER1);
   enable_interrupts(INT_TIMER2);
   enable_interrupts(INT_TIMER3);
   enable_interrupts(INT_EXT);
   enable_interrupts(INT_EXT1);
   enable_interrupts(GLOBAL);
   lcd_init();
   delay_ms(6);
   lcd_gotoxy(4,1);
   lcd_putc("Welcome");
   
   
}

void main()
{
   setup();
   
   while(1)
   {
     
   }
   
}


for the time being please on focus on the EXT ISR, ignore the rest.

To test I am feeding an input on RB0 but the routing is not being executed.

Code:

#int_EXT
void  EXT_isr(void)
{
  zc_count++;
  if (zc_count == 3)
  {
   period_read = get_timer1();
   set_timer1(0);
   zc_count = 0;
  }

}


I checked everything twice but still nothing is working for the interrupt. Can somebody help me?

Thanks
Ttelmah



Joined: 11 Mar 2010
Posts: 19552

View user's profile Send private message

PostPosted: Mon Mar 11, 2013 9:26 am     Reply with quote

You are doing a port wide output on portB after setting the TRIS. This will set the tris on the whole port as _output_, so B0, can't work as an interrupt input.

Best Wishes
aaronik19



Joined: 25 Apr 2011
Posts: 297

View user's profile Send private message

PostPosted: Mon Mar 11, 2013 11:29 am     Reply with quote

Thanks Telmah. That was the problem. Everything is working now. In my example, I have put the RB0 (bit1) as "1" and the other bits as output "0". So if I have bit 6 and bit 7 as outputs how I can deal with this in TRIS?
asmboy



Joined: 20 Nov 2007
Posts: 2128
Location: albany ny

View user's profile Send private message AIM Address

PostPosted: Mon Mar 11, 2013 11:47 am     Reply with quote

deal with this in TRIS?

covered in user manual
SherpaDoug



Joined: 07 Sep 2003
Posts: 1640
Location: Cape Cod Mass USA

View user's profile Send private message

PostPosted: Mon Mar 11, 2013 11:49 am     Reply with quote

aaronik19 wrote:
Thanks Telmah. That was the problem. Everything is working now. In my example, I have put the RB0 (bit1) as "1" and the other bits as output "0". So if I have bit 6 and bit 7 as outputs how I can deal with this in TRIS?


1) Output individual bits to port B instead of the whole port.
2) Use TRIS after setting port B so the Int bit is an input.
3) Use fixed_IO instead of TRIS.
4) Use bit_test() to set the Int bit as an input
_________________
The search for better is endless. Instead simply find very good and get the job done.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group