PDA

View Full Version : @goto not working please help



cluster
- 31st October 2011, 14:45
hello,
the below code first erase memory location and then write some code from external eeprom and then uses goto statement to jump to execute new code. everything is working properly except the goto statement. it return back without executing the code. target pic is pic18f4550. i am using DT_INTS-18 and DT_HID260 for usb. i would really appreciate any help.


for aa = $69A0 to $6B9F step 64
erasecode aa
next aa
for aa = $69A0 to $6B9F
i2cread sda, SCL, $A1, cc, [w2]
writecode aa, w2
cc = cc + 1
next aa
@goto 0x69A0

my idea is to store firmware in external eeprom and then programming 18f4550 from it, similar to bootloader but using external eeprom
thank you

Darrel Taylor
- 31st October 2011, 15:39
The Flash blocks of 64 bytes are at physical boudaries.
$69A0 is in the middle of the block that begins at $6980.

The next block starts at $69C0.
You have to write exactly 64 bytes per block, and the write to flash doesn't actually happen until the last of the 64 bytes is sent.

Also, there needs to be a space between the @ sign and goto.

cluster
- 31st October 2011, 16:40
The Flash blocks of 64 bytes are at physical boudaries.
$69A0 is in the middle of the block that begins at $6980.

The next block starts at $69C0.
You have to write exactly 64 bytes per block, and the write to flash doesn't actually happen until the last of the 64 bytes is sent.

Also, there needs to be a space between the @ sign and goto.
thank you Darrel for you response
18f4550 datasheet states that write to program memory is executed on blocks of 32 bytes at a time and program memory is erased in blocks of 64 bytes at a time. i have also checked 18f4550 program memory using programmer, code does get written to flash.
i tired putting space between @ sign and goto it didn't helped much :(

if i don't use DT_INTS-18 and DT_HID260 then @ goto statement works, i think because there are no interrupts to disturb the @ goto.
but i want to use them because i want USB functionality and easy way of interrupts. so how do i use three of them together DT_INTS-18, DT_HID260 and @ goto

thank you

Darrel Taylor
- 31st October 2011, 17:23
Right you are. 32 bytes.
Sorry, I was looking at the erase size.

I don't see why it shouldn't work with the interrupts. It's just like jumping to any other part of the program.

How do you get the code that is being loaded from EEPROM?
Is it compiled separately?
Was it compiled at the correct address?

cluster
- 31st October 2011, 18:45
Was it compiled at the correct address?
many thanks Darrel, it now worked.
i never gave it a thought. you made my day.