PDA

View Full Version : pic18f4550 hangs.. RX_INT DT_INTS-18.. please help



cluster
- 6th November 2011, 03:58
Hello
below is my code. i am using pic18f4550. light start to blink as expected but when anything is sent serially it hangs pic and blinking light stops.


DEFINE RESET_ORG 0x1000
DEFINE OSC 48
adcon1 = 15

DEFINE HSER_RCSTA 90h
DEFINE HSER_TXSTA 20h
DEFINE HSER_BAUD 9600
SerialData var byte
RXIF VAR PIR1.5
TXIF VAR PIR1.4

DEFINE USE_LOWPRIORITY 1
;--- Setup Interrupts ------------------------------------------------------
INCLUDE "DT_INTS-18.bas" ; Base Interrupt System
include "ReEnterPBP-18.bas"
include "ReEnterPBP-18LP.bas"

ASM
INT_LIST macro ; IntSource, Label, Type, ResetFlag?
INT_Handler USB_Handler
endm
INT_CREATE ; Creates the interrupt processor

INT_LIST_L macro ; IntSource, Label, Type, ResetFlag?
INT_Handler RX_INT, _Receive, PBP, no
endm
INT_CREATE_L
endasm

@ INT_ENABLE RX_INT

;--- Setup USB -------------------------------------------------------------
INCLUDE "DT_HID260.pbp"

DEFINE USB_VENDORID 6017
DEFINE USB_PRODUCTID 2000
DEFINE USB_VERSION 1
DEFINE USB_VENDORNAME "Test"
DEFINE USB_PRODUCTNAME "Test"
DEFINE USB_SERIAL "001"
DEFINE USB_INSIZE 64;32 ; IN report is PIC to PC (8,16,32,64)
DEFINE USB_OUTSIZE 64;16 ; OUT report is PC to PIC
DEFINE USB_POLLIN 10 ; Polling times in mS, MIN=1 MAX=10
DEFINE USB_POLLOUT 10

; --- Each USB LED is optional, comment them if not used ----
DEFINE USB_LEDPOLARITY 1 ; LED ON State [0 or 1] (default = 1)
DEFINE USB_PLUGGEDLED PORTB,0 ; LED indicates if USB is connected
DEFINE USB_TXLED PORTC,2 ; " " data being sent to PC
DEFINE USB_RXLED PORTC,1 ; " " data being received from PC

main:
Toggle porta.0
pause 50
goto main

Receive:
HSERIN [Serialdata]
hserout [Serialdata,13,10]
back:
@ INT_RETURN

any suggestions appreciated.
thank you

cluster
- 6th November 2011, 13:02
ok i think i found the issue and its because of reset vector. i am using bootloader to send firmware, after bootloader writes the firmware it works till interrupt occurs.

can anyone tell how to rewrite/change reset vector in PBP, i have searched but didn't found anything?
thank you

HenrikOlsson
- 6th November 2011, 13:34
Hi,
Which bootloader are you using?
Usually when using a bootloader you do DEFINE LOADER_USED 1 but to answer your question you should be able to do DEFINE RESET_ORG 0080h or whatever.

/Henrik.

cluster
- 6th November 2011, 13:59
Hi Henrik,

Thanks for reply. i am sorry i mean interrupt vector

i have written my own code similar to bootloader using PBP and DT-INTS. this is what happens, it first receive firmware from USB and writes it to external EEPROM, then read it and reprogram flash and jump to the new firmware (@goto). Now i think my issue is when an interrupt occurs in the new firmware it looks into bootloader interrupt vector for corresponding routine to execute, since no reference exists there it hangs/resets. if somehow i can put new interrupt vector then i think problem would be solved.
i would really appreciate any suggestions
thank you

HenrikOlsson
- 6th November 2011, 16:32
Oh! Yeah, that's a bit of a difference....
The interrupt vectors are as far as I know something defined in the hardware of the chip itself. Location 0x0008h is the high priority interrupt vector and 0x0018h is the low priority interrupt vector. I don't see any way to change that.

Are both your bootloader AND the application using DT-INTS? I have no idea how that should/would/could work....

/Henrik.