|
Forum Index : Microcontroller and PC projects : PEEK(CFUNADDR X)
| Author | Message | ||||
| crez Senior Member Joined: 24/10/2012 Location: AustraliaPosts: 152 |
Hi All, I have a cfunction called C1234 saved in the library. When I run this: A%=Peek(CFUNADDR C1234) Print A%, Hex$(A%) Print Peek(BYTE A%) I get an error about the address a% not being accepted. > RUN 2634346540 9D04F02C [3] Print Peek(BYTE A%) Error: Address > Why doesn't peek(byte a%) like it? It accepts &h9d000000. |
||||
| Geoffg Guru Joined: 06/06/2011 Location: AustraliaPosts: 3308 |
The "Address" error means that you were trying to access outside of the valid memory address range for the flash. For the MX470 the valid range is 0x9D000000 to 0x9D07FFFF and for the MX170 it is 0x9D000000 to 0x9D03FFFF What chip are you using? The PEEK() function itself should be working OK but I am currently in Japan and cannot test it for some weeks. Geoff Geoff Graham - http://geoffg.net |
||||
| crez Senior Member Joined: 24/10/2012 Location: AustraliaPosts: 152 |
Hi Geoff, I'm using the 28 pin DIL MX170. mm.ver=5.0405 I have a 256 byte table of hex bytes to use in a program and I thought I could enter them as a 'non executable' cfunction, saving the repeated use of &h in a DATA statement, and then access them using PEEK. It's a bit of a 'hack', but I couldn't see why it wouldn't work. |
||||
| Geoffg Guru Joined: 06/06/2011 Location: AustraliaPosts: 3308 |
This is strange, the address 0x9D04F02C is in the reserved range, so you should not be able to store anything there. I think that the problem is with the number returned by Peek(CFUNADDR C1234) and I can guess the cause. In a CFunction the first word (4 bytes) is used to hold the offset (in words) from the start of the CFunction to the first executable function in the CFunction. The PEEK(CFUNCTION) function automatically adds this value to the address of the CFunction so that it returns the address of the executable code. But your CFunction does not contain executable code, instead the first word is probably part of your data table. The solution is simple, the first word of your data table should be zero. Then Peek(CFUNADDR C1234) will return the address of the first data in your table (after the first word which is zero). Geoff Geoff Graham - http://geoffg.net |
||||
| crez Senior Member Joined: 24/10/2012 Location: AustraliaPosts: 152 |
You hit the nail on the head! Now I just have to deal with the way the 32 bit words appear in reverse order in the memory. Thanks for your help. I hope the typhoon on the news here isn't affecting you. David |
||||
| Geoffg Guru Joined: 06/06/2011 Location: AustraliaPosts: 3308 |
The typhoon has been interesting. Over the past 24 hours the rain and wind steadily increased to quite high levels then it went quiet as the eye passed over (about 4 hours ago). Now we have a blue sky and just a strong wind. The Japanese are unconcerned, this is just normal stuff for them. Geoff Geoff Graham - http://geoffg.net |
||||
| twofingers Guru Joined: 02/06/2014 Location: GermanyPosts: 1671 |
Perhaps this thread may help. Regards Michael causality ≠ correlation ≠ coincidence |
||||
| The Back Shed's forum code is written, and hosted, in Australia. | © JAQ Software 2025 |