<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Unusual interrupt behaviour in Kinetis Microcontrollers</title>
    <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/Unusual-interrupt-behaviour/m-p/1427741#M62622</link>
    <description>&lt;P&gt;There is an obscure foot note in the data sheet, that says the IRQ mode and GPIO mode configurations must match for that pin.&amp;nbsp; There is no explanation as to what happens when they do not match.&amp;nbsp; Perhaps we just found out?&lt;BR /&gt;&lt;BR /&gt;Also an active low configuration will stay in that IRQ for as long as the input is low, unless the IRQ is disabled in the service routine.&amp;nbsp; This could be causing something else to malfunction from not being serviced.&amp;nbsp; I don't know what an active high configuration does. This is why edge trigger is usually used.&lt;BR /&gt;&lt;BR /&gt;Switch bounce also needs to be accounted for, perhaps it is, didn't see it in the code snippet.&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://www.ganssle.com/debouncing.htm" target="_blank" rel="noopener"&gt;http://www.ganssle.com/debouncing.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 14 Mar 2022 12:42:33 GMT</pubDate>
    <dc:creator>bobpaddock</dc:creator>
    <dc:date>2022-03-14T12:42:33Z</dc:date>
    <item>
      <title>Unusual interrupt behaviour</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/Unusual-interrupt-behaviour/m-p/1427342#M62612</link>
      <description>&lt;P&gt;I am building a digital modulator for a hand-held radio. When the transmit button is pushed, it triggers an interrupt on GPIOC bit 18.&amp;nbsp; I have tested it with both of the edge triggers and also high-level triggers and it works fine.&amp;nbsp; When I switch to low-level triggers it crashes as soon as it executes&amp;nbsp;&lt;/P&gt;&lt;P&gt;NVIC_EnableIRQ(PORTC_IRQn);&amp;nbsp;&lt;/P&gt;&lt;P&gt;The voltage on the pin is 2.1V whne the button is not pushed, so it is definitely recognising a HI as it interrupts fine when the button is not pressed and I set it to HI level trigger with the following instruction:&lt;/P&gt;&lt;P&gt;PORTC_PCR18 = 0xC0100;&lt;/P&gt;&lt;P&gt;(Yes, the PTT switch works backwards perfectly.&amp;nbsp; So it must be recognising a true LO when the switch is pushed.&lt;/P&gt;&lt;P&gt;But why does it crash when I use:&lt;/P&gt;&lt;P&gt;PORTC_PCR18 = 0x80100; ???&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt; */
#include &amp;lt;stdio.h&amp;gt;
#include "board.h"
#include "peripherals.h"
#include "pin_mux.h"
#include "clock_config.h"
#include "MK64F12.h"
#include "fsl_debug_console.h"
#include "GUMP.h"
#include "frere.h"
#include "stdint.h"
//#include "inttypes.h"
#include "stdio.h"
#include "string.h"
#include "fsl_dspi.h"  // not found in mcuexpresso, taking chance of copying from KDS 2022 02 10 NWJ
#include "board.h"
#include "pin_mux.h"
#include "clock_config.h"

#define DSPI_MASTER_BASEADDR SPI1
#define DSPI_MASTER_CLK_SRC DSPI1_CLK_SRC
#define DSPI_MASTER_CLK_FREQ CLOCK_GetFreq(DSPI1_CLK_SRC)
#define DSPI_MASTER_IRQ SPI1_IRQn
#define DSPI_MASTER_PCS kDSPI_Pcs0
#define DSPI_MASTER_IRQHandler SPI1_IRQHandler

#define DSPI_SLAVE_BASEADDR SPI1
#define DSPI_SLAVE_IRQ SPI1_IRQn
#define DSPI_SLAVE_IRQHandler SPI1_IRQHandler
//#define TRANSFER_SIZE 256U        // Transfer dataSize
#define TRANSFER_SIZE 10        // Transfer dataSize
#define TRANSFER_BAUDRATE 500000U // Transfer baudrate - 500k

#define SPI_PUSHR_PCS0_ON 0x10000
#define SPI_PUSHR_PCS1_ON 0x20000
#define SPI_PUSHR_PCS2_ON 0x40000
#define SPI_PUSHR_PCS3_ON 0x80000
#define SPI_PUSHR_PCS4_ON 0x100000
#define SPI_PUSHR_PCS5_ON 0x200000
#define SPI_CTAR_FMSZ_8BIT 0x38000000
#define SPI_CTAR_FMSZ_16BIT 0x78000000

#define INIT 1                          // arguments for the lcd routine
#define UPDATE 2                        //
const char line1[]="Frere Radio     ";
const char line2[]="System    V0.1  ";

const char line1a[]="Copyright(c)2022";
const char line2a[]="Nigel W. Johnson";

const char line1b[]="                ";
const char line2b[]="                ";

unsigned char cmd = 0x01;
unsigned char receiveBuffer[3];

uint8_t masterRxData[TRANSFER_SIZE] = {0U};
uint8_t masterTxData[TRANSFER_SIZE] = {0U};
uint8_t slaveRxData[TRANSFER_SIZE] = {0U};
uint8_t slaveTxData[TRANSFER_SIZE] = {0U};

volatile uint32_t slaveTxCount;
volatile uint32_t slaveRxCount;

volatile uint32_t masterTxCount;
volatile uint32_t masterRxCount;
volatile uint32_t masterCommand;
uint32_t masterFifoSize;

dspi_master_handle_t g_m_handle;
dspi_slave_handle_t g_s_handle;

volatile bool isTransferCompleted = false;

//#pragma section m_data

char RAM_line1[16];
char RAM_line2[16];

unsigned char a[16];

char *pointer;
char temp;
int char_Pos;                           // where we are in LCD line
int dest;
int i;
unsigned int  TxHex,RxHex;
unsigned char TxHex1,TxHex2,TxHex3,TxHex4;			// storage for raw data in hex and unpacked digits
unsigned char RxHex1,RxHex2,RxHex3,RxHex4;			// storage for raw data in hex and unpacked digits

unsigned short ADC_read16b(void);
unsigned short bADCData;
void send_spi(void);
void receive_spi(void);

/*
 * @brief   Application entry point.
 */
int main(void)
{
	 SIM_SCGC5 |= SIM_SCGC5_PORTC_MASK;       /*Enable Port C Clock Gate Control*/
	 PORTC_PCR18  = 0x80100;         		 /*PORTC_PC18: ISF=0,IRQC=A (Low-level trigger ,MUX=1 */
	 GPIOC_PDDR |= (0 &amp;lt;&amp;lt; 18);                 /*Setting the bit 6 of the port C as Input*/
	 PORTC_ISFR = PORT_ISFR_ISF(0x40);       /* Clear interrupt status flag */
     NVIC_EnableIRQ(PORTC_IRQn);             /*Enable the PORTC interrupt*/

&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 13 Mar 2022 16:02:27 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/Unusual-interrupt-behaviour/m-p/1427342#M62612</guid>
      <dc:creator>ve3id</dc:creator>
      <dc:date>2022-03-13T16:02:27Z</dc:date>
    </item>
    <item>
      <title>Re: Unusual interrupt behaviour</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/Unusual-interrupt-behaviour/m-p/1427429#M62618</link>
      <description>&lt;P&gt;Hi&lt;/P&gt;
&lt;P&gt;What's the voltage of VDD? Why the voltage of PORTC18 is 2.1v when not pushed. If there is no external pull up&amp;nbsp;resistor, then please enable the internal pull up&amp;nbsp;resistor for PORTC18. (PORTx_PCRn[PE][PS]) You can refer the SDK example.(...\SDK_2_11_0_FRDM-K64F\boards\frdmk64f\driver_examples\gpio\input_interrupt)&lt;/P&gt;
&lt;P&gt;Notice: If the pin is configured for a level sensitive interrupt and the pin remains asserted, then the flag is set again immediately after it is cleared.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please measure the voltage of PORTC18 by using oscilloscope, check the value meet the VIH VIL.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="2.2.1 Voltage and current operating requirements.png" style="width: 764px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/173455iF94F81DC1F5C6D06/image-size/large?v=v2&amp;amp;px=999" role="button" title="2.2.1 Voltage and current operating requirements.png" alt="2.2.1 Voltage and current operating requirements.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Best Regards,&lt;BR /&gt;Robin&lt;BR /&gt;-------------------------------------------------------------------------------&lt;BR /&gt;Note:&lt;BR /&gt;- If this post answers your question, please click the "Mark Correct" button. Thank you!&lt;/P&gt;
&lt;P&gt;- We are following threads for 7 weeks after the last post, later replies are ignored&lt;BR /&gt;Please open a new thread and refer to the closed one, if you have a related question at a later point in time.&lt;BR /&gt;-------------------------------------------------------------------------------&lt;/P&gt;</description>
      <pubDate>Mon, 14 Mar 2022 03:31:10 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/Unusual-interrupt-behaviour/m-p/1427429#M62618</guid>
      <dc:creator>Robin_Shen</dc:creator>
      <dc:date>2022-03-14T03:31:10Z</dc:date>
    </item>
    <item>
      <title>Re: Unusual interrupt behaviour</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/Unusual-interrupt-behaviour/m-p/1427741#M62622</link>
      <description>&lt;P&gt;There is an obscure foot note in the data sheet, that says the IRQ mode and GPIO mode configurations must match for that pin.&amp;nbsp; There is no explanation as to what happens when they do not match.&amp;nbsp; Perhaps we just found out?&lt;BR /&gt;&lt;BR /&gt;Also an active low configuration will stay in that IRQ for as long as the input is low, unless the IRQ is disabled in the service routine.&amp;nbsp; This could be causing something else to malfunction from not being serviced.&amp;nbsp; I don't know what an active high configuration does. This is why edge trigger is usually used.&lt;BR /&gt;&lt;BR /&gt;Switch bounce also needs to be accounted for, perhaps it is, didn't see it in the code snippet.&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://www.ganssle.com/debouncing.htm" target="_blank" rel="noopener"&gt;http://www.ganssle.com/debouncing.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 14 Mar 2022 12:42:33 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/Unusual-interrupt-behaviour/m-p/1427741#M62622</guid>
      <dc:creator>bobpaddock</dc:creator>
      <dc:date>2022-03-14T12:42:33Z</dc:date>
    </item>
    <item>
      <title>Re: Unusual interrupt behaviour</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/Unusual-interrupt-behaviour/m-p/1427822#M62625</link>
      <description>&lt;P&gt;Thank you, Robin and Bob,&lt;/P&gt;&lt;P&gt;I have temporarily&amp;nbsp; fixed the problem by:&lt;/P&gt;&lt;P&gt;if(GPIOC_PDIR &amp;amp; 0x40000)&lt;BR /&gt;PORTC_ISFR = PORT_ISFR_ISF(0x40000); // Clear bit 18 interrupt status flag&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;because there is nothing else needed to be done in the radio if the PTT button is pushed.&lt;/P&gt;&lt;P&gt;However, I'd like to make sure it is all clean - so the Vdd is 3.29V Hi logic on PTC-14 is 2.1V low is 50mV&lt;/P&gt;&lt;P&gt;With PE + PS set to 1 in the PCR, ViH is now 2.34V, but setting LO level for interrupt still crashes on startup.&lt;/P&gt;&lt;P&gt;Going back to&amp;nbsp;PORTC_PCR18 = 0xA0103;&amp;nbsp; restores workable operation.&lt;/P&gt;&lt;P&gt;I think for now I will leave it that way - no point in going into and out of ISR thousads of times when PTT pushed.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 14 Mar 2022 16:07:33 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/Unusual-interrupt-behaviour/m-p/1427822#M62625</guid>
      <dc:creator>ve3id</dc:creator>
      <dc:date>2022-03-14T16:07:33Z</dc:date>
    </item>
  </channel>
</rss>

