Thanks, I haven't clean up the code yet. That makes sense about the unexpected issues.
Thanks, I haven't clean up the code yet. That makes sense about the unexpected issues.
"No one is completely worthless. They can always serve as a bad example."
Anonymous
This program having SERIN2 working together with a USB connection keeps giving me headaches. The first code below works fine for many straight hours and days. However the second code gets hung up after half an hour or so. This SUB is called once every second more or less. Is there anything that I'm missing here? Why does the second code gets hung up after a while?
THIS CODE WORKS FINE:
THIS CODE GETS HUNG UP AFTER A WHILE:Code:SearchForClockSignal: @ INT_DISABLE USB_INT PIR2.5 = 0 SERIN2 PORTB.7, 32, 5, CLOCKSEARCHFAILED, [STR RFID_IN\7] @ INT_ENABLE USB_INT '.... SOME CODE HERE TO PROCESS THE DATA CLOCKSEARCHFAILED: @ INT_ENABLE USB_INT RETURN
Code:SearchForClockSignal: @ INT_DISABLE USB_INT PIR2.5 = 0 FOR J = 0 TO 5 SERIN2 PORTB.7, 32, 5, CONTINUESERIN2, [STR RFID_IN\7] CONTINUESERIN2: USBSERVICE IF RFID_IN[0] = 252 THEN EXIT 'THE DATA PACKAGE WAS RECEIVED NEXT J @ INT_ENABLE USB_INT '.... SOME CODE HERE TO PROCESS THE DATA CLOCKSEARCHFAILED: RETURN
"No one is completely worthless. They can always serve as a bad example."
Anonymous
since only code snippets posted and
no hardware description pic/usb descriptor and
no explanation why eusart not employed and
no description of failure point or why "working" code not suitable
for a meaningful forum response more detail would not go astray.
i'm only a novice at usb stuff at best but there is just not enough data to go on for me.
in general i would not expect two such asynchronous time critical services to ever be reliable on a single core device
without some hardware support.
some thoughts
SearchForClockSignal:
@ INT_DISABLE USB_INT
PIR2.5 = 0 ? why here
FOR J = 0 TO 5
SERIN2 PORTB.7, 32, 5, CONTINUESERIN2, [STR RFID_IN\7] ? 5ms ? usb can be polled at intervals down to 1ms device dependent
// what is your actual poll frequency ? use wireshark to get a picture of whats happening
CONTINUESERIN2:
USBSERVICE
IF RFID_IN[0] = 252 THEN EXIT 'THE DATA PACKAGE WAS RECEIVED
NEXT J
// no attempt here to clear irq flag before re engaging isr could be an issue
@ INT_ENABLE USB_INT
'.... SOME CODE HERE TO PROCESS THE DATA
CLOCKSEARCHFAILED:
RETURN
Warning I'm not a teacher
Bookmarks