View previous topic :: View next topic |
Author |
Message |
nailuy
Joined: 21 Sep 2010 Posts: 159
|
interrupt with INT_CCP1 are not interrupting printf, |
Posted: Sun Sep 21, 2014 12:34 pm |
|
|
Hy
I discovered code like:
setup_timer_1(T1_INTERNAL|T1_DIV_BY_8);
setup_ccp1(CCP_CAPTURE_FE);
enable_interrupts(INT_CCP1);
enable_interrupts(GLOBAL);
is not interrupting working of code like:
printf(LCD_SEND_C,"%Lu ",TEST);
so when I receive FE edge, I must put an output logically high.
#int_CCP1
void CCP1_v1()
{
output_bit(OUT,1);
}
and is not working.
Any solution will be better than nothing
Best regards. |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Sun Sep 21, 2014 12:43 pm |
|
|
Post your compiler version. There was a printf/GIE bug in some versions.
Always post your version. |
|
|
nailuy
Joined: 21 Sep 2010 Posts: 159
|
|
Posted: Sun Sep 21, 2014 1:05 pm |
|
|
Version 4.140
.................... setup_timer_1(T1_INTERNAL|T1_DIV_BY_8);
03DB: MOVLB 02
03DC: BCF 1D.5
03DD: MOVLW 35
03DE: MOVLB 00
03DF: MOVWF 18
03E0: CLRF 19
.................... setup_ccp1(CCP_CAPTURE_FE);
03E1: MOVLB 01
03E2: BSF 0E.2
03E3: MOVLB 05
03E4: CLRF 13
03E5: MOVLW 04
03E6: MOVWF 13
03E7: CLRF 14
03E8: CLRF 15
03E9: BCF 1E.0
03EA: BCF 1E.1
03EB: MOVLW 01
03EC: MOVWF 16
.................... enable_interrupts(INT_CCP1);
03ED: MOVLB 01
03EE: BSF 11.2
.................... enable_interrupts(GLOBAL);
03EF: MOVLW C0
03F0: IORWF 0B,F
.................... printf(LCD_SEND_C,"%Lu ",TEST);
0417: MOVLW 41
0418: MOVWF 04
0419: MOVF 4B,W
041A: MOVWF 55
041B: MOVF 4A,W
041C: MOVWF 54
041D: MOVF 49,W
041E: MOVWF 53
041F: MOVF 48,W
0420: MOVWF 52
0421: MOVLB 00
0422: GOTO 29E
0423: MOVLW 57
0424: MOVLB 03
0425: MOVWF 11
0426: MOVLW 01
0427: MOVWF 12
0428: BSF 03.0
0429: MOVLW 07
042A: MOVLB 04
042B: MOVWF 52
042C: MOVLB 00
042D: GOTO 303
Best regards. |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Sun Sep 21, 2014 1:25 pm |
|
|
I installed vs. 4.140 and made a test program and looked at the .LST file
and I can't find any place where it disables interrupts. So either your
version doesn't have that bug, or you are doing something in your code
that you are not showing us. For example, you may have more code in
the #int_ccp1 routine than you are showing us. Or, you may have
another interrupt routine which has delay_ms() in it. I suspect you are
doing something like that.
Code: |
#include <18F4520.h>
#fuses INTRC_IO, BROWNOUT, PUT, NOWDT
#use delay(clock=4M)
//#use rs232(baud=9600, UART1, ERRORS)
#include "flex_lcd.c"
#define OUT PIN_B0
#int_CCP1
void CCP1_v1()
{
output_bit(OUT,1);
}
void LCD_SEND_C(int8 c)
{
lcd_putc(c);
}
//=============================
void main()
{
int16 TEST = 1234;
setup_timer_1(T1_INTERNAL|T1_DIV_BY_8);
setup_ccp1(CCP_CAPTURE_FE);
enable_interrupts(INT_CCP1);
enable_interrupts(GLOBAL);
printf(LCD_SEND_C,"%Lu ",TEST);
while(1);
} |
|
|
|
nailuy
Joined: 21 Sep 2010 Posts: 159
|
|
Posted: Sun Sep 21, 2014 1:38 pm |
|
|
Yes
I use on printf my code for LCD 2X8.
and use half of data of pins.
when I send data like is on data sheet I must enable pin E for minimum 2ms.
so when is this pin enabled interrupt not working?
how can I "fix" this or change?
Thank you. |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Sun Sep 21, 2014 2:16 pm |
|
|
I don't know. I can't help without seeing a test program that shows
the problem. |
|
|
nailuy
Joined: 21 Sep 2010 Posts: 159
|
|
Posted: Sun Sep 21, 2014 2:41 pm |
|
|
I will post a piece of code.
is too big and is my work please understand. |
|
|
nailuy
Joined: 21 Sep 2010 Posts: 159
|
|
Posted: Mon Sep 22, 2014 9:45 am |
|
|
so in my code for LCD I have:
#define LCD_ENABLE (output_bit(LCD_E,1), delay_ms(2), output_bit(LCD_E,0), delay_us(1))
can you help?
Thank you. |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9226 Location: Greensville,Ontario
|
|
Posted: Mon Sep 22, 2014 10:49 am |
|
|
You should post your LCD module however I assume that you really need delay_us(2) and NOT delay_ms(2) in your define.
If you read the LCD.C example that CCS supplies they use delay_us().
hth
jay |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Mon Sep 22, 2014 11:04 am |
|
|
I don't see anything in the little amount of code that you have posted so
far, that shows any problem. And the the problem can be caused by
other things, than just using delay routines inside and outside an isr.
Make sure that warnings are enabled for display by the CCS compiler.
Then compile your program. Look at the "Build Window" output report.
Does it say "Interrupts Disabled to Prevent Re-entrancy".
In fact, right here is your previous thread where you are doing this:
http://www.ccsinfo.com/forum/viewtopic.php?t=52882
Are you still doing it ? Are you still getting the "Interrupts Disabled"
message ? If so, stop calling CCS routines inside and outside your
interrupt routines, or use the solutions given to you in that previous thread. |
|
|
nailuy
Joined: 21 Sep 2010 Posts: 159
|
|
Posted: Mon Sep 22, 2014 1:36 pm |
|
|
Dear PCM Programmer
As I said that problem I solved by shifting ">>2"
I have 0 Errors, 0 Warnings.
Dear temtronic look at this on page: 15 ...
http://www.tme.eu/ro/Document/a9f385851814a23749414e1b9da83876/RC0802A-BIW-CSX.pdf
... after display clear I must use enable pin at least 1520us, approx 2ms for every time when I use enable pin.
The problem is on this:
#define LCD_ENABLE (output_bit(LCD_E,1), delay_ms(2), output_bit(LCD_E,0), delay_us(1))
how can I use 2 ms but not to be higher priority than #int_CCP1
I look forward for your reply. |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9226 Location: Greensville,Ontario
|
|
Posted: Mon Sep 22, 2014 2:41 pm |
|
|
I've downloaded the documentation and feel you're not reading it correctly.
On page 13, Writing from MPU to LCD..., the enable pulse width needs to be a minimum of 140 ns, so it is like most LCD units I've seen and should work fine with the flex_lcd.c driver.
What you're writing about is the lcd_init sequence which is ONLY done ONCE, when you run your program. The driver takes care of this in th einit() function.
You really should start all over and code a basic 'Hello World' program with NO interrupts. It'll be about 10 lines of code. You need to get that working 100% BEFORE you proceed with anything more complicated.
Post your 'Hello World' code for us....
hth
jay |
|
|
nailuy
Joined: 21 Sep 2010 Posts: 159
|
|
Posted: Tue Sep 23, 2014 12:32 am |
|
|
temtronic
I think you are right, I will test your solution and I will be back with reply.
I hope is okay time 1-2us. (for 140ns).
Best regards. |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9226 Location: Greensville,Ontario
|
|
Posted: Tue Sep 23, 2014 5:13 am |
|
|
Just to let you know, EVERY LCD module I've every used in the past 20 years has worked fine with the 'flex_lcd' driver so I know the delays are fine.
jay |
|
|
nailuy
Joined: 21 Sep 2010 Posts: 159
|
|
Posted: Wed Oct 01, 2014 4:18 pm |
|
|
yes is working but not full
instead of 2ms I have 4 us, with lower than 4 is not working.
#define LCD_ENABLE (output_bit(LCD_E,1), delay_us(4), output_bit(LCD_E,0), delay_us(1))
I verify entire data sheet but is still something wrong maybe.
I will study.
Best regards. |
|
|
|