Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 12:47 10 Nov 2025 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : PEEK(CFUNADDR X)

Author Message
crez

Senior Member

Joined: 24/10/2012
Location: Australia
Posts: 152
Posted: 02:43am 22 Oct 2017
Copy link to clipboard 
Print this post

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: Australia
Posts: 3308
Posted: 03:40am 22 Oct 2017
Copy link to clipboard 
Print this post

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: Australia
Posts: 152
Posted: 10:59am 22 Oct 2017
Copy link to clipboard 
Print this post

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: Australia
Posts: 3308
Posted: 12:29pm 22 Oct 2017
Copy link to clipboard 
Print this post

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: Australia
Posts: 152
Posted: 01:57pm 22 Oct 2017
Copy link to clipboard 
Print this post

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: Australia
Posts: 3308
Posted: 03:55pm 22 Oct 2017
Copy link to clipboard 
Print this post

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: Germany
Posts: 1671
Posted: 10:34pm 22 Oct 2017
Copy link to clipboard 
Print this post

  crez said   Now I just have to deal with the way the 32 bit words appear in reverse order in the memory.

Perhaps this thread may help.
Regards
Michael
causality ≠ correlation ≠ coincidence
 
Print this page


To reply to this topic, you need to log in.

The Back Shed's forum code is written, and hosted, in Australia.
© JAQ Software 2025