I'v reduced it to just the parts needed to compile and show the error.
The problem I'm having is the 'CRCDATL' line in 'Case 5' of the interrupt routine.
When the .Payload.RcvdChksum variable is used without the .byte modifier, it compiles correct...Rxbyte in Case5 goes to the CRCDATL register.
When I add the '.byte' modifier to it, the CRCDATL addresses all change to 0x0980 when compiled...!
I'm compiling with Microchip 16 compiler, XC16 v1.33, although is does the same with Firewing16, target board doesn't matter.
Thanks much
- Code: Select all
Device = 24FJ128GA204 // Select processor
clock = 32 // Define system clock as Fosc/2
/**************** ENUM / STRUCTURES *****************/
structure payload_t
RcvdChksum as ushort
end structure
structure S300_t
Payload as payload_t
end structure
/**************** VARIABLES *****************/
Dim RX1STATE as byte = 0
dim U1packet as S300_t
'****************************************************************************
'* Name : OnRX1 (Private) *
'* Purpose : Interrupt Service Routine (ISR) to receive incoming data *
'****************************************************************************
Interrupt OnRX1(Pic.U1RXInterrupt)
dim RXbyte as byte = U1RXREG
with U1Packet
select case RX1STATE
// Get bytes
case 5
CRCDATL.byte0 = RXbyte ' NEED TO SEND BYTE (NOT WORD) TO CRC..
// Get data checksum
case 6
'.Payload.RcvdChksum = RXbyte ' THIS WORKS
.Payload.RcvdChksum.byte0 = RXbyte ' THIS DOESN'T...The RXbyte above is sent to 0x0980 instead!
end select
end with
End Interrupt
/**************** MAIN PROGRAM *****************/
sub main()
Enable (OnRX1)
// MAIN LOOP
while (true)
end while
end sub
