Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Programming COM1,2 Ports in DOS (with interrupts)

Status
Not open for further replies.

ramyadhadidi

Junior Member level 1
Joined
Jan 12, 2012
Messages
17
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,412
Programming hardware interrupts

I'm wirting a program that needs UART chip on PC. I want to service UART in ISR.
I run my program in VMware on DOS. And my program can read serial data using polling method(COM1). So data is comming. But My program dont jump to ISR.
I put my code here,
thanks for your help
Code:
INI_UART_COM1 MACRO         
  ;intialization of uart COM1
  ;maped to 3F8H and IRQ4 (I.V.T add=C)
      ;set dlab=1
      MOV DX,3FBH
      MOV AL,10000000B
      OUT DX,AL
      ;set devisors (64)(10800 buad rate)
      MOV DX,3F8H
      MOV AL,40H
      OUT DX,AL      
      MOV DX,3F9H
      MOV AL,00H
      OUT DX,AL 
      ;clr dlab-no parity-1stop-8bit data
      MOV DX,3FBH
      MOV AL,00000011B
      OUT DX,AL
      ;set interupt for reci. data
      MOV DX,3F9H
      MOV AL,0000_0001B
      OUT DX,AL   
ENDM

INI_UART_COM2 MACRO  
  ;intialization of uart COM2
  ;maped to 3F8H and IRQ3 (I.V.T add=B)
      ;set dlab=1
      MOV DX,2FBH
      MOV AL,10000000B
      OUT DX,AL
      ;set devisors (64)(10800 buad rate)
      MOV DX,2F8H
      MOV AL,40H
      OUT DX,AL      
      MOV DX,2F9H
      MOV AL,00H
      OUT DX,AL 
      ;clr dlab-no parity-1stop-8bit data
      MOV DX,2FBH
      MOV AL,00000011B
      OUT DX,AL
      ;set interupt for reci. data
      MOV DX,2F9H
      MOV AL,01H
      OUT DX,AL   
ENDM


;;my code without begining!!
      IN AL,21H
      AND AL,1110_0111B
      OUT 21H,AL
      INI_UART_COM1
      INI_UART_COM2
      ;SET IVT TABLE
      MOV AX,0000H
      MOV ES,AX
      MOV WORD PTR ES:[0030H],OFFSET COM1_INT
      MOV WORD PTR ES:[0032H],SEG COM1_INT
      
      MOV WORD PTR ES:[002CH],OFFSET COM2_INT
      MOV WORD PTR ES:[002EH],SEG COM2_INT
      
      MOV AH,02H
      MOV DL,CR
      INT 21H
      
      STI
MOO:  NOP
      JMP MOO

COM1_INT PROC FAR 
                  MOV AH,02H
                  MOV DL,'r'
                  INT 21H 
                  
                  MOV DX,3F8H
                  IN AL,DX
                  MOV AH,02H
                  MOV DL,AL
                  INT 21H 
                  
                  MOV AL,20H
                  OUT 20H,AL
                  JMP COM1_INT
      
COM1_NO_INT:      STI
                  IRET  
COM1_INT ENDP

I also check IRQ addresses with MSD.exe. All of them is changed to my program ISR.
I think no Interrupt is enabled.
please help
 
Last edited:

Re: Programming hardware interrupts

Is it necessary to write it in Assembly?
If you can Use TurboC-2.0 then most of your problem will be solved.

The asvantage of TC is it has Get_vect and set_vect routines which minimizes your efforts.

as far as i remember you have to use "CLI" then save the ORIGINAL vector, Then put your code in IVT and Do a "STI"

I used to write DOS code 15 years back though :-D
 

In a generic DOS system, you need to configure the interrupt controller for the interrupt as well. I don't see this in your code.
 

Re: Programming hardware interrupts

CLI and STI: I used them. nothing happens
IVT: there is no need to save that! I just restart my VMware. this code is not the final verssion. I only want to check UART interrupt.
and about C! I need assembly code and all details

---------- Post added at 17:29 ---------- Previous post was at 17:25 ----------

I thought interrupt controller (16550) was set by DOS from begining. Cause to write ICWs we need to reset chip by hardware method and we dont have this ability
we need OCWs. so in code I read OCW1 (mask register) and change it. and also I issue a nomral end of interrupt (EOI) in my ISRs.
do you think I need to do more thant this to int. controller?
 

Re: Programming hardware interrupts

Well If this doc may be of help...flint.cs.yale.edu/cs422/doc/art-of-asm/pdf/CH17.PDF

see section 17.4.4
 

Re: Programming hardware interrupts

thank you!
but I do the same as it says, I read mask reagister and enable IRQ3 and 4 in it
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top