Review your favorite Linux distribution.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 04-27-2017, 03:27 AM   #1
LQ Newbie
Registered: Apr 2017
Posts: 1

Rep: Reputation: Disabled
Coding serial ISR for UART 16550 under Linux kernel 3.18

I have a problem with my ISR made on the basis of http:// an Interrupt Service Routine for the serial port in Linux !! post. Here is my code:
#include <linux/kernel.h>
#include <linux/module.h>	
#include <linux/interrupt.h> 
#include <linux/version.h>
#include <linux/fs.h>
#include <asm/io.h>
#include <asm/signal.h>
#include <linux/irq.h>
#define PORT 0x3F8

void delayedOp (unsigned long currentlyUnused);
DECLARE_TASKLET (rs232Tasklet, delayedOp, 0);

static int times;
static unsigned char znak;
unsigned char status, intr_identify;
irq_handler_t isrSerialPort (int irq, void *dev_id, struct pt_regs *regs)
	printk (KERN_ALERT "\nisrSerialPort called %d ", times);

	intr_identify = inb( PORT + 2 ) & 0x0F;
	if ( intr_identify == 0x01 ) return  IRQ_NONE;
	if ( intr_identify == 0x04 )     // a new character has arrived 
	znak=inb( PORT );
	printk ("   irq =  %x, intr = %x ", znak,intr_identify);
	tasklet_schedule (&rs232Tasklet);
	return (irq_handler_t) IRQ_HANDLED;

int init_module ()
	int	status;
	int result = request_irq (4, (irq_handler_t) isrSerialPort, IRQF_DISABLED, "softbrainISR", NULL);

	outb(0x0b,PORT+4);	//ster_modem - DTR,RTS,OUT2
	outb( 0x07, PORT + 2 );	// turn off FIFO-mode 
	inb(PORT+6);	//stan_modem
	inb(PORT+5);	//status_port
	inb(PORT);		//dane
	outb(0x8b,PORT+3);		//LCR=1, param_trans = 0x0b - parity even (b3-b5), 1 bit stopu(b2), 8 bitów danych (b0,b1)
							//03 - dla parity none
	outb(0x0c,PORT);		//9600 bodów
	outb(0x0b,PORT+3);		//LCR=0
	outb(01,PORT+1);		//przerwanie od odbiornika aktyw_przerw=1
	printk (KERN_INFO "\ncinit_module called\n");
	return result;

void delayedOp (unsigned long currentlyUnused)
	printk ("\nznak =  %x ", znak);

void cleanup_module ()
	free_irq (4, NULL);
	printk (KERN_INFO "\ncleanup_module called\n");
The problem is that the first interrupt doesn't come - the first character I send comes after I send the next character and so on... In effect I never get the last one - It waits for interrupt until next character.

Where is the problem?
Please help me
Old 04-28-2017, 07:48 PM   #2
LQ Guru
Registered: Jan 2005
Location: USA and Italy
Distribution: Debian testing/sid; OpenSuSE; Fedora; Mint
Posts: 5,524

Rep: Reputation: 1015Reputation: 1015Reputation: 1015Reputation: 1015Reputation: 1015Reputation: 1015Reputation: 1015Reputation: 1015
Hi Anna,

Welcome to LQ!

OK, for this you must learn the debugger. It will allow you to step through the code while monitoring what is going on. If I had to figure this out, that is what I'd need to do.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem with Kernel driver and Serial / UART Port sm4rty Linux - Kernel 1 04-02-2016 03:27 AM
[SOLVED] 8250/16550 driver assumes a 1.8432 MHz serial clock, mine is 2.4576 MHz dbrazeau Linux - Kernel 3 03-04-2016 03:28 PM
[SOLVED] Coding an Interrupt Service Routine for the serial port in Linux !! Aquarius_Girl Programming 12 01-01-2013 01:36 AM
Problem in interrupt handler for uart 16550 mrinal mishra Linux - Kernel 3 05-05-2006 01:00 AM
jpilot/serial UART? amam Linux - General 1 11-01-2001 01:16 AM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 08:42 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration