SXB Interrupt problem
Hi,
A have written an interrupt routine in SX/B for blinking a LED in different ways (50% duty cycle or selectable LED on/off time) I will be a part of an IR gate program.
This program is working fine on SX28. I can place WATCH-s ·for the variablesin the program and can see them in debug mode.
I can start, stop, reset, etc the program in debug mode. (Is is working good.)
Programming this code into the chip the LED are blinking as I wanted. (using 4MHz internal osc.)
But!!! When I tried to use this code on SX48 os SX52 I run into strange problem. In debug mode I can only reset the program is is continously running. I can't stop it. (The stp button is not selectable.) I can not the WATCH changes.
I programmed the code into the chip, but the LED was not blinking as I wanted. (It seems that the interupt·is not working.)
I tried other not interrup codes(PORT I/O and TIMER)·on the SX48 and SX52 chips they was working, but the debug mode was working in the same way as with the interrupt routine.
I should tell that these chips are very old, as I remeber I got them as an engineering sample in 1998 or 1999. Can be this chips interrup and debug handling are not complette? Sould I by new ones? What Your suggestion?
Regards
Spiller
A have written an interrupt routine in SX/B for blinking a LED in different ways (50% duty cycle or selectable LED on/off time) I will be a part of an IR gate program.
This program is working fine on SX28. I can place WATCH-s ·for the variablesin the program and can see them in debug mode.
I can start, stop, reset, etc the program in debug mode. (Is is working good.)
Programming this code into the chip the LED are blinking as I wanted. (using 4MHz internal osc.)
But!!! When I tried to use this code on SX48 os SX52 I run into strange problem. In debug mode I can only reset the program is is continously running. I can't stop it. (The stp button is not selectable.) I can not the WATCH changes.
I programmed the code into the chip, but the LED was not blinking as I wanted. (It seems that the interupt·is not working.)
I tried other not interrup codes(PORT I/O and TIMER)·on the SX48 and SX52 chips they was working, but the debug mode was working in the same way as with the interrupt routine.
I should tell that these chips are very old, as I remeber I got them as an engineering sample in 1998 or 1999. Can be this chips interrup and debug handling are not complette? Sould I by new ones? What Your suggestion?
Regards
Spiller
Comments
If you could post the code you are using on the SX48/SX52 chips I will try it. But if you can try a newer chip, that may be the problem. I know some things changed on the SX48/SX52 (like the bank bits).
Bean.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
www.iElectronicDesigns.com
·
Here ia the code:
'
' Program Description
'
' 1. Device address:
'
' All PORTs are inputs with intenal pullup
'
' Addr_0 - RA0
' Addr_1 - RA1
' Addr_2 - RA2
' Addr_3 - RA3
'
' 2. IR LED driver IC (U427B pin 1) control:
'
' Ir_Led - RB6 - Output
'
' 3. Control LED driver use IR driver IC STANDBY circuit (U427B pin 2):
'
' Contr_Led - RB7 - Output
'
' 4. RS485 IC (SN75176B) reveiver:
'
' Ser_In - RB4 - Input
'
' 5. RS485 IC (SN75176B) transmitter:
'
' Ser_Out - RB5 - Output
'
'
' Device Settings
'
DEVICE SX48, OSCXT2', TURBO, STACKX, OPTIONX
FREQ 4_000_000
ID "SXB_AITR"
'
' IO Pins
'
Addr VAR RA ' device address
TRIS_A_PORT VAR TRIS_A
PLP_A_PORT VAR PLP_A
Ser_In VAR RB.4 ' RS485 input
Ser_Out VAR RB.5 ' RS485 output
Ir_Led VAR RB.6 ' IR LED driver output
Ctrl_Led VAR RB.7 ' control LED output
TRIS_B_PORT VAR TRIS_B
TRIS_C_PORT VAR TRIS_C
Ir_Mod VAR RC.2 ' IR LED modulator signal
'
' Constants
'
'
' Variables
'
Addr_Mem VAR Byte ' address memory
Led_On_Time VAR Byte ' control LED on timer
Led_Off_Time VAR Byte ' control LED off timer
Mode_Bit VAR Bit ' mode bit
Led_Flag VAR Bit ' control LED staus flag
'
INTERRUPT 200
'
ISR_Start:
IF Mode_Bit = 1 THEN Test_Blink
IF Led_Flag = 0 THEN Led_Off
Led_On: ' LED normal mode
Led_Flag = 1 ' set control LED flag to one
HIGH Ctrl_Led ' switch on control LED
Led_Off_Time = 0 ' clear control LED off timer
INC Led_On_Time ' increment control LED on timer
IF Led_On_Time = 5 THEN Led_Off
GOTO ISR_Exit
Led_Off:
Led_Flag = 0 ' set control LEd flag to zero
LOW Ctrl_Led ' switch off control LED
Led_On_Time = 0 ' clear controll LED on timer
INC Led_Off_Time ' increment control LED on timer
IF Led_Off_Time = 250 THEN Led_On
GOTO ISR_Exit
Test_Blink: ' LED test mode
INC Led_On_Time
IF Led_On_Time = 100 THEN Led_Toggle ' LED blinking on 1 Hz
GOTO ISR_Exit
Led_Toggle:
TOGGLE Ctrl_Led ' toggle control LED
Led_On_Time = 0 ' clear control LED on timer
ISR_Exit:
RETURNINT '156 ' {cycles} 200.32 Hz
' =========================================================================
PROGRAM Start
' =========================================================================
'
' Subroutine Declarations
'
'
' Program Code
'
Start: ' initialization
TRIS_A_PORT = %1111 ' configuring A PORT to input
PLP_A_PORT =%0000 ' pullup A port
TRIS_B_PORT = %0001_1111 ' configuring B PORT
' RB7,RB6,RB5 output,
' other RB input
HIGH Ctrl_Led ' set RB7 low
LOW Ir_Led ' set RB6 Low
LOW Ser_Out ' set RB5 low
TRIS_C_PORT = %1111_1101 ' configuring C PORT
' RC2 output, others input
LOW Ir_Mod ' set RC2 low
Addr_Mem = 0 ' clear address memory
Led_On_Time = 0 ' control LED on timer
Led_Off_Time = 0 ' control LED off timer
Mode_Bit = 0 ' set mode bit to test mode
Led_Flag = 1 ' set control LED status flag to one
'OPTION = $86 ' enable interrupt with prescaler 1:128
Main: ' main program
Read_Addr: ' read device addres
' Addr_Mem = Addr
'Mode_Sel: ' mode selection
' IF Addr_Mem = 0 THEN Test_Mode
'Command_Mode: ' entering command mode
' Mode_Bit = 1
' GOTO Read_Addr
Test_Mode: ' entering test mode
Mode_Bit = 0
Ctrl_Led = ~Ctrl_Led
PAUSE 500
GOTO Read_Addr
END
Regards
Spiller
I forgat to to remove the Led bilinking not IT routine at the end of my code. I have added it when the IT rouutine was not working for checking that the SX48 chicp was good at all. (This was working.)
Regards
Spiller
Bean.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
www.iElectronicDesigns.com
·
First, thanks for Your support.
May plan is to modulate the IR LED with timers, that is why I like to switch to SX48. I know some SX/B command (like SERIN, SEROUT) my interfer with the interrupt routine. That is the main reason I turned to SX48.
This small IT routine was my first idea, which was working on SX28 well, but not on my old SX48 and SX52 chips. I like to clarify only that my SX48 and SX52 chips are bad or not.·So, can the chips bad? (I have ordered new SX48 already, and will go on with them.)
Jonny,
Thanks for the attached ASM routine.
Regards
Spiller
The SX28 program I provided is written in SX/B -- it just contains assembly segments to replace PAUSE, SERIN, and SEROUT so you can modulate the IR LED with the interrupt. You don't have to use any more assembly in the program; use high-level SX/B in the Main section and you're good to go.
In the event your foreground program could be busy when a byte comes in, you can use the attached version which is updated to include 8-byte buffers for RX and TX.
Post Edited (JonnyMac) : 2/1/2008 4:15:35 PM GMT
Thanks, I will try it with my new SX48 chips (ordered today) which I will get tomorrow. (I think my old ones not working well, because I commented out everything except the interrupt routine which should run but not. When I tried on SX28 it is okay.)
Regards
Spiller