• 11
• 9
• 11
• 9
• 11
• entries
686
1952
• views
386921

# And then there were errors...

92 views

I finished the entire code for Pong Advanced, but now I'm getting this error that I can't get around. It's on this line of code:

*(unsigned long*)0x4000000 = (0x5 | 0x400);

Here is the error:

Quote:
 parse error before "unsigned"

Any suggestions?

You are trying to set a constant to a constant?
I know what you mean to do, but thats my only guess as to why its buggin.
Quote:
 Now, this would work just fine but there are some issues with this code. First there is the fact that since these are hardware registers we may not be the only ones changing them. This is something the compiler needs to know else it will try to optimize our code and likely break it. The way we tell the compiler that variables change outside of the c code is to declare them volatile. The last issue is that we are using a variable (RAM) to store a constant. We would be much better served if we just used a #define…this also allows us to dereference the register in its declaration and makes writing to it a bit simpler. Here is the new, more proper code. #define REG_DISPCNT (*(volatile unsigned short*)0x4000000) REG_DISPCNT = 0x5|0x400; 

Source: The Pern Project.

I was gonna write that myself...but its explained so well in The Pern Project tutorials.

Made that change, but It still dosen't work. Can't really find out whats wrong...

What is the issue now?