Interrupt with Button

A catchall for PSoC Mixed-Signal Array (microcontroller) discussions not captured by the other forums.

Moderator: ericb

Interrupt with Button

Postby Skillet » Thu Apr 03, 2014 12:33 am

Hi, i'm a begginner with Psoc
i use the C8C27443 24PXI
the button is wired to the +5v and to the P0[1]; (StdCPU; Pull Down; RisingEdge)

My Goal is to send an I2C data when i push the button so i want to use the interrupt.
My code is :

Code: Select all
#include <m8c.h>        // part specific constants and macros
#include "PSoCAPI.h"    // PSoC API definitions for all User Modules
#include "delay.h"
int data;
#pragma interrupt_handler PSoC_GPIO_ISR_C


void main(void)
{   
   LED_GLO_Start();
   LED_THT_Start();
   I2CHW_1_Start();
   I2CHW_1_EnableMstr();
   I2CHW_1_EnableInt();
   M8C_EnableGInt ;
   M8C_EnableIntMask(INT_MSK0,INT_MSK0_GPIO);

        while (1);
}

void PSoC_GPIO_ISR_C()
{
   if (PRT0DR & 0x02)
   {
      I2CHW_1_fSendStart(0x20,0);
      I2CHW_1_fWrite(0x10);
      //I2CHW_1_SendStop();
      //I2CHW_1_fReadBytes(0x21, data, 0x01, I2CHW_1_CompleteXfer);
      //Delay10msTimes(100);
      I2CHW_1_fSendStart(0x20,1);
      //Delay10msTimes(100);
      data=I2CHW_1_bRead(1);
      I2CHW_1_SendStop();
      Delay10msTimes(100);
      if (data==0x10)
         {
            LED_GLO_On();
         }
   }   
   
}


Can U help me because when i pressed the button it's not work :/
Skillet
Newbie
Newbie
 
Posts: 2
Joined: Thu Apr 03, 2014 12:22 am

Re: Interrupt with Button

Postby danadak » Thu Apr 03, 2014 5:20 am

You need to modify boot.tpl in root project directory, the interrupt vector -

http://www.cypress.com/?id=4&rID=36720

http://www.cypress.com/?rID=2900

Regards, Dana.
Field Application Engineer
KB1RHB Mostly listen :)
Semi Retired
User avatar
danadak
The Big Cheese
The Big Cheese
 
Posts: 2008
Joined: Thu Dec 27, 2007 8:42 am
Location: New Hampshire

Re: Interrupt with Button

Postby Skillet » Thu Apr 03, 2014 10:53 am

Oh Yeah it's work fine thanks a lot,
I did not know he had to modifie the .asm

thanks for you're help
Skillet
Newbie
Newbie
 
Posts: 2
Joined: Thu Apr 03, 2014 12:22 am

Re: Interrupt with Button

Postby danadak » Thu Apr 03, 2014 1:07 pm

Don't forget to debounce your button. If you send me a private message
with your email address I can forward the info to you, its too large to post
on forum, they have a 2 MB limit.

Regards, Dana.
Field Application Engineer
KB1RHB Mostly listen :)
Semi Retired
User avatar
danadak
The Big Cheese
The Big Cheese
 
Posts: 2008
Joined: Thu Dec 27, 2007 8:42 am
Location: New Hampshire

Re: Interrupt with Button

Postby bobmarlowe » Fri Apr 04, 2014 12:40 am

@Dana
Has debouncing become more complicate within the last years? I remember that you provided us in this forum with information regarding this topic and there was no need for sending them per mail. :mrgreen:

So I would like to get knowledge about the de-bouncing methods you collected, too. Will you please send them to me as well?


Bob
User avatar
bobmarlowe
The Big Cheese
The Big Cheese
 
Posts: 1490
Joined: Thu Oct 06, 2011 2:03 am
Location: Germany

Re: Interrupt with Button

Postby danadak » Fri Apr 04, 2014 2:00 am

The zip file is 7 MB, so what I must have posted prior is a partial of info
I have. How many ways can one debounce you ask ? I am sure I only have
a fraction of the available methods.

Your email address is ?

Regards, Dana.
Field Application Engineer
KB1RHB Mostly listen :)
Semi Retired
User avatar
danadak
The Big Cheese
The Big Cheese
 
Posts: 2008
Joined: Thu Dec 27, 2007 8:42 am
Location: New Hampshire


Return to “%s” PSoC1 General

Who is online

Users browsing this forum: Bing [Bot] and 1 guest