public inbox for ecos-devel@sourceware.org
 help / color / mirror / Atom feed
From: Michael Jones <mjones@linear.com>
To: "ecos-devel@ecos.sourceware.org" <ecos-devel@ecos.sourceware.org>
Subject: Problem setting up an ISR for a K60 PORT
Date: Tue, 19 Feb 2013 00:13:00 -0000	[thread overview]
Message-ID: <A60E30AB-6F4C-4A0E-8B39-BC76435B33D2@linear.com> (raw)

I am struggling to setup an ISR/DSR for a PORT on the K60. My goal is to get an ISR/DSR when Pin 19 of PORTA transitions from high to low. This is pin PTA19 of the device.

My non-working code and complete code below.

What the code tries to do is setup PORTA PIN19 as input. Then take the PCR register and set the interrupt to work off a falling edge. 

Then create the ISR/DSR.

When I toggle the pin, nothing happens. 

FYI the hardware works with MQX, so I know the hardware is ok. I use it the same way under MQX where I get an ISR from a negative edge. And I have put a scope on it to make sure there is an edge. So I am quite sure the problem is the code.

This code was generated by trying to understand the Kinetis code, but things were not clear to me. Some macros use __pin to mean different things. So this is my best guess.

Does anyone know how to do this?

PORT SETUP CODE
================

    cyghwr_hal_kinetis_port_t *port_p;

	CYGHWR_HAL_KINETIS_GPIO_PIN_DDR_IN(ALERT_PORT, ALERT_PIN);

    // Get address for PORTA
    port_p = Ports[0];

    // 0xA means interrupt on falling edge.
    // Read modify write PCR
    port_p->pcr[ALERT_PIN] =
    		(port_p->pcr[ALERT_PIN] & 0xFFF0FFFF) |
			(0xA << 16);

    // Create an ISR/DSR for PORTA.
    // Assuming the priority is what the DSR will run at.
    // No data passed.
	cyg_interrupt_create(
			CYGNUM_HAL_INTERRUPT_PORTA, // Vector
			3, 							// Priority
			(cyg_addrword_t)0, 			// Data
			alert_isr, 					// ISR
			alert_dsr, 					// DSR
			&alert_handle,		 		// Handle
			&alert_interrupt);			// INTR
	cyg_thread_suspend(cyg_thread_self());
}

ALL CODE
=========

#ifndef ALERT_H_
#define ALERT_H_

#include <cyg/kernel/kapi.h>
#include <cyg/hal/var_io_gpio.h>
#include <cyg/hal/drv_api.h>
#include <cyg/hal/var_io.h>

#define ALERT_PORT A
#define ALERT_PIN 19

extern void start_alert(cyg_addrword_t data);

#endif

#include "alert.h"

cyg_handle_t alert_handle;
cyg_interrupt alert_interrupt;

cyghwr_hal_kinetis_port_t * const Ports[] = {
    CYGHWR_HAL_KINETIS_PORTA_P, CYGHWR_HAL_KINETIS_PORTB_P,
    CYGHWR_HAL_KINETIS_PORTC_P, CYGHWR_HAL_KINETIS_PORTD_P,
    CYGHWR_HAL_KINETIS_PORTE_P
};

cyg_uint32 alert_isr( cyg_vector_t vector,
                              cyg_addrword_t data
)
{
	return CYG_ISR_HANDLED | CYG_ISR_CALL_DSR;
}

void alert_dsr( cyg_vector_t vector,
                        cyg_ucount32 count,
                        cyg_addrword_t data
                      )
{

}

void pmbus_alert_callback(void)
{


}

void start_alert(cyg_addrword_t data)
{
    cyghwr_hal_kinetis_port_t *port_p;

	CYGHWR_HAL_KINETIS_GPIO_PIN_DDR_IN(ALERT_PORT, ALERT_PIN);

    // Get address for PORTA
    port_p = Ports[0];

    // 0xA means interrupt on falling edge.
    // Read modify write PCR
    port_p->pcr[ALERT_PIN] =
    		(port_p->pcr[ALERT_PIN] & 0xFFF0FFFF) |
			(0xA << 16);

    // Create an ISR/DSR for PORTA.
    // Assuming the priority is what the DSR will run at.
    // No data passed.
	cyg_interrupt_create(
			CYGNUM_HAL_INTERRUPT_PORTA, // Vector
			3, 							// Priority
			(cyg_addrword_t)0, 			// Data
			alert_isr, 					// ISR
			alert_dsr, 					// DSR
			&alert_handle,		 		// Handle
			&alert_interrupt);			// INTR
	cyg_thread_suspend(cyg_thread_self());
}


             reply	other threads:[~2013-02-19  0:13 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-02-19  0:13 Michael Jones [this message]
2013-02-19  8:34 ` Lambrecht Jürgen
2013-02-19 14:51   ` Michael Jones

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=A60E30AB-6F4C-4A0E-8B39-BC76435B33D2@linear.com \
    --to=mjones@linear.com \
    --cc=ecos-devel@ecos.sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).