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.

[ARM] LPC2136 interrupt not working UART0 __irq

Status
Not open for further replies.

rtoribio

Newbie level 2
Joined
Jun 3, 2018
Messages
2
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
30
hello freinds,

I am using LPC2136 on MDK-lite v-5.25 with legacy pluggins to run ARM7TDMI, but i dont know why this code is not working with interrupt on UART0 __irq this can not TX0 and RX0.

here all my funtions and codes:


Code C - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
#include "LPC213X.h"
#include <stdint.h>
#include "ST7735.h"
 
 
extern void initPLL(void);
extern void SPI_init(void);
extern void Serial0_init(void);
extern const uint16_t Logo[];                       //Imagen logo utesa.
extern void UART0_Interrupt_EN(void);
extern void init_gpiox(void);
__irq void UART0Handler (void);
void delay(void);
char rxdat;
 
int main(void)
{
    int x, y, dx, dy;
    init_PLL();
    SPI_init();
    Serial0_init();
    init_gpiox();
    UART0_Interrupt_EN();
    while(1);
    U0THR= 'A';
    U0THR= 'B';
    IO0SET |= 0x00000080;
    delay();
    IO0CLR |= 0x00000080;
    ST7735_FillScreen(0xFFFF);            // set screen to white
  x = 15; //44
  y = 130; //159
  dx = 1;
  dy = 0;
  while(1){
        //ST7735_DrawBitmap(x, y, Logo, 40, 160);
    ST7735_DrawBitmap(x, y, Logo, 96, 96);
    x = x + dx;
    y = y + dy;
    if((x >= (ST7735_TFTWIDTH - 40 + 15)) || (x <= -15)){
      dx = -1*dx;
    }
    if((y >= (ST7735_TFTHEIGHT + 8)) || (y <= (ST7735_TFTHEIGHT - 8))){
      dy = -1*dy;
    }
  }
 
//  while(1);
    
}
 
__irq void UART0Handler (void)  
{
    rxdat = U0RBR;
        VICVectAddr= 0x00000000;
        IO0SET |= 0x00000080;
        delay();
        IO0CLR |= 0x00000080;
}
 
void delay(void)
{
    uint32_t i;
    for(i=0;i<=320000;i++);
}
 
 
------------------------------------------------------------------------------------
void Serial0_init(void)
{
    PINSEL0=0x00050000;             //Habilitar TDX0 RDX0.
    U0FCR=0x01;
    U0LCR=0x00000083;                   //8bits, no paridad y bit de stop.
    U0DLL=85;                                       //Velocidad de puerto serial 9600 baudios.
    U0DLM=0x0;
    U0FDR= 0x0000005E;              //  MULVAL = 0x5 and DIVADDVAL = 14
    U0LCR= 0x00000003;              //DLAB = 0.
    U0IER= 0x00000003;              //Interrupciones habilitadas en el puerto serial 0.
}
-------------------------------------------------------------------------------------
 
 
extern __irq void UART0Handler (void);
 
void UART0_Interrupt_EN(void)
{
    VICIntSelect = 0x00000000; 
    VICVectAddr0 = (unsigned int) UART0Handler;             //Vector 0 para la interrupcion serial
    VICVectCntl0 = 0x26;                        //select UART0 interrupt as IRQ i.e vector 0
    VICIntEnable = 0x00000040;
}

 
Last edited by a moderator:

Sorry that was in my last test i didnt remove it.

Code:
#include "LPC213X.h"
#include <stdint.h>
#include "ST7735.h"


extern void initPLL(void);
extern void SPI_init(void);
extern void Serial0_init(void);
extern const uint16_t Logo[];						//Imagen logo utesa.
extern void UART0_Interrupt_EN(void);
extern void init_gpiox(void);
void delay(void);
char rxdat;

int main(void)
{
	int x, y, dx, dy;
	init_PLL();
	SPI_init();
	Serial0_init();
	init_gpiox();
	UART0_Interrupt_EN();
	while(!(U0LSR&0x20));                 //THRE = 0 stay here
	U0THR= 'R';
	while(!(U0LSR&0x20));                 //THRE = 0 stay here
	U0THR= 'A';
	while(!(U0LSR&0x20));                 //THRE = 0 stay here
	U0THR= 'U';
	while(!(U0LSR&0x20));                 //THRE = 0 stay here
	U0THR= 'L';
	while(!(U0LSR&0x20)); 
	while(1);
	U0THR= 'B';
	IO0SET |= 0x00000080;
	delay();
	IO0CLR |= 0x00000080;
	ST7735_FillScreen(0xFFFF);            // set screen to white
  x = 15; //44
  y = 130; //159
  dx = 1;
  dy = 0;
  while(1){
		//ST7735_DrawBitmap(x, y, Logo, 40, 160);
    ST7735_DrawBitmap(x, y, Logo, 96, 96);
    x = x + dx;
    y = y + dy;
    if((x >= (ST7735_TFTWIDTH - 40 + 15)) || (x <= -15)){
      dx = -1*dx;
    }
    if((y >= (ST7735_TFTHEIGHT + 8)) || (y <= (ST7735_TFTHEIGHT - 8))){
      dy = -1*dy;
    }
  }

//	while(1);
	
}

void UART0Handler (void)  __irq 
{
		while(!(U0LSR & 0x01));                        //RDR = 0 stay here
    rxdat = U0RBR;
		VICVectAddr= 0x00000000;
		IO0SET |= 0x00000080;
		delay();
		IO0CLR |= 0x00000080;
}

void delay(void)
{
	uint32_t i;
	for(i=0;i<=320000;i++);
}

My problem is when i try to recieved data from  (rxdat = U0RBR;) is not jumping to the _irq funtion:

is not working

void UART0Handler (void)  __irq 
{
		while(!(U0LSR & 0x01));                        //RDR = 0 stay here
    rxdat = U0RBR;
		VICVectAddr= 0x00000000;
		IO0SET |= 0x00000080;
		delay();
		IO0CLR |= 0x00000080;
}
 

What i am seeing is infinite loop in the irq function. Generally you should never be in an infinite loop in an interrupt function.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top