It is currently Wed Dec 13, 2017 11:32 pm

All times are UTC - 7 hours





Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: Correctly read addresses
PostPosted: Tue Feb 25, 2014 8:20 am 
Offline

Joined: Tue Dec 03, 2013 11:51 am
Posts: 6
Hello,
it's been a while since my last post.
I have updated my circuit a little bit, but it's still not working as I want it to.
I added a little picture to show you my current circuit. All 16 address lines of the GameBoy are tied together in groups of 8 to two NANDS. The outputs of the NANDS are connected to a NOR.
So basically, if all address lines (A0 - A15) are on VCC (which should happen if I read 0xFFFF), there should be a logical 1 at the output of the NOR.
In the other picture you see the output of the NOR on a oscilloscope while reading OxFFFF in a infinite loop. I put some red circles around the peaks (where it is on VCC).
The problem now is: If I change my program so that it reads e.g. 0x0000 NOTHING changes. The output on the oscilloscope remains exactly the same. So that means, my program for reading the address is not correct.

Code:
#include <gb/gb.h>
#include <stdio.h>
#include <stdlib.h>

void main()
{
   int *adresse;
   int value;
            
   for(;;)
   {
      *address = 0x0000;
      value= *address;                  
   }
}


That's my program. If anyone of you has an idea how to correctly read an address so that it changes the address lines, I would very appreciate if he/she would let me know.
Many thanks in advance.


Attachments:
Circuit.jpg
Circuit.jpg [ 1.87 MiB | Viewed 1559 times ]
Osci.jpg
Osci.jpg [ 1.56 MiB | Viewed 1559 times ]
Top
 Profile  
 
PostPosted: Tue Feb 25, 2014 8:50 am 
Offline
Formerly ~J-@D!~
User avatar

Joined: Sun Mar 12, 2006 12:36 am
Posts: 445
Location: Rive nord de Montréal
Monster704 wrote:
Code:
#include <gb/gb.h>
#include <stdio.h>
#include <stdlib.h>

void main()
{
   int *adress;
   int value;
   for(;;)
   {
      *address = 0x0000;
      value= *address;                  
   }            
}

If I understand correctly, you want to read from some fixed addresses? I guess what you wanted in your for loop is
Code:
   for(;;)
   {
      address = (int *)0x0000;
      value= *address;                  
   }

If it's the solution you're after, maybe you should read more about C pointers because you appear not to grasp basic concepts about them.


Top
 Profile  
 
PostPosted: Tue Feb 25, 2014 11:32 am 
Offline

Joined: Sun Apr 13, 2008 11:12 am
Posts: 6520
Location: Seattle
Monster704: break it down into parts. What's the output of one of the NAND8s? What does the 'scope show going into its inputs?

Also, I don't know whether SDCC will compile int type to a single byte on the gbz80 target.


Top
 Profile  
 
PostPosted: Tue Feb 25, 2014 9:05 pm 
Offline

Joined: Sat Aug 28, 2010 9:01 am
Posts: 199
Why do you expect the logic gate to trigger on a read from $0000? A nand gate will be high as soon as of its inputs are low. At least one input is low at all times during the execution of the "read from $0000" variation of our program, and thus nothing will ever happen. Only a read (or write) from (to) $ffff will create a change in the final output. If you did actually change the 8-input NANDs to 8-input NORs etc for the second experiment, then I apologize for sounding rash.

But anyway, I recommend getting BGB since it has a powerful debugger and is accurate enough to pretty much render hardware testing obsolete. (You should still test anything you plan to release on hardware to be sure ) You can enter the debugger by pressing esc in the emulator window. You can now single step and edit different types of breakpoints.

What you want in this case is an access breakpoint. In the debugger, select debug, access breakpoints. Enter the desired address, check write and/or read as desired and finally press add. Run (F9 or run, run in the menu bar) and see if it triggers.

lidnariq wrote:
Also, I don't know whether SDCC will compile int type to a single byte on the gbz80 target.
Tis doesn't matter hugely for the purposes of the experiment. If int is bigger than a byte, the code will still read from $0000. It will not read only from $0000, but if the goal is to produce a read from $0000 it's sufficient.

I'd be more worried that the read is optimized away. $ffff might implicitly be classified as volatile, preventing the read from being optimized away, whereas a read from $0000 would not be classified as volatile.


Top
 Profile  
 
PostPosted: Wed Feb 26, 2014 10:02 am 
Offline

Joined: Tue Dec 03, 2013 11:51 am
Posts: 6
First of all I want to thank all of you for your answers.
Jarhmander wrote:
Monster704 wrote:
Code:
#include <gb/gb.h>
#include <stdio.h>
#include <stdlib.h>

void main()
{
   int *adress;
   int value;
   for(;;)
   {
      *address = 0x0000;
      value= *address;                  
   }            
}

If I understand correctly, you want to read from some fixed addresses? I guess what you wanted in your for loop is
Code:
   for(;;)
   {
      address = (int *)0x0000;
      value= *address;                  
   }

If it's the solution you're after, maybe you should read more about C pointers because you appear not to grasp basic concepts about them.


That sounds plausible...could be that I mixed something up here! I will try that the next time I am in the laboratory.

lidnariq wrote:
Monster704: break it down into parts. What's the output of one of the NAND8s? What does the 'scope show going into its inputs?

Also, I don't know whether SDCC will compile int type to a single byte on the gbz80 target.


Last time I didn't have the time to break it down into parts..will definitely do that the next time!

nitro2k01 wrote:
Why do you expect the logic gate to trigger on a read from $0000? A nand gate will be high as soon as of its inputs are low. At least one input is low at all times during the execution of the "read from $0000" variation of our program, and thus nothing will ever happen. Only a read (or write) from (to) $ffff will create a change in the final output. If you did actually change the 8-input NANDs to 8-input NORs etc for the second experiment, then I apologize for sounding rash.

But anyway, I recommend getting BGB since it has a powerful debugger and is accurate enough to pretty much render hardware testing obsolete. (You should still test anything you plan to release on hardware to be sure ) You can enter the debugger by pressing esc in the emulator window. You can now single step and edit different types of breakpoints.

What you want in this case is an access breakpoint. In the debugger, select debug, access breakpoints. Enter the desired address, check write and/or read as desired and finally press add. Run (F9 or run, run in the menu bar) and see if it triggers.

lidnariq wrote:
Also, I don't know whether SDCC will compile int type to a single byte on the gbz80 target.
Tis doesn't matter hugely for the purposes of the experiment. If int is bigger than a byte, the code will still read from $0000. It will not read only from $0000, but if the goal is to produce a read from $0000 it's sufficient.

I'd be more worried that the read is optimized away. $ffff might implicitly be classified as volatile, preventing the read from being optimized away, whereas a read from $0000 would not be classified as volatile.


I did not expect the logic gate to trigger on a read from 0x0000. When we first set up our circuit on a test board I wrote a short program (the one in my starting post) which continuously reads from 0xFFFF and that the logic gate is triggering correctly. The picture of the oscilloscope is from the logic output while reading from 0xFFFF. I (and my teacher) thought that the short peaks (in the red circles) are from the 0xFFFF read.
After that I changed the the program so that it reads from 0x0000, to see if something changes. Unfortunately the output remained exactly the same.
The circuit is correct (double checked everything)...

I haven't heard of BGB yet, I will definitely give it a try. Thank you!


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC - 7 hours


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group