First,
volatile const uint8_t * TargetPointer; is declared that way because
unless I added the const gcc complains
I think what I am supposed to be doing there is declaring TargetPointer
to be a pointer to a constant unsigned byte (ie uint8_t) The array Room1
is an array of constant uint8_t
Second switch (Room1[0]) would always to the same thing. Since Room1[0]
would never change. Where as TargetPointer is supposed to be assigned
the address of the 1st byte of the array Room1 later in the code
TargetPointer is incremented and basically walks the array.
The problem is not with the code but the debugger. I can see that
TargetPointer get assigned the address of Room1 like it should but the
array Room1 does not contain the byte sequence that it should.
-----Original Message-----
From: Jose Fuentes [mailto:josecarlosfuentes@yahoo.com.ar]
Sent: Monday, February 07, 2005 10:06 AM
To: AVR-Chat@yahoogroups.com
Subject: Re: [AVR-Chat] Having trouble debugging a piece of code.
Some comments:
//why do you declare TargetPointer as const?
volatile const uint8_t * TargetPointer;
//try this instead of using TempPointer, TargetPointer
switch (Room1[0])
//also, don't forget the 'break' sentence after
//every case block
Regards
Jose
--- wbounce <wbounce@safeplace.net> escribió:
>
> I am having trouble debugging a piece of code that
> used to work. I using
> avr-gcc (GCC) 3.4.1 with AVR Studio 4.10.356 as my
> debugging tool
> dwarf-2. I have the following code which is not
> working. The listing
> shows Room1 as it should but in AVR Sutdio it does
> not show up correctly
> and hence my switch code fails. What actually shows
> in the Room1 array
> varies greatly. Something it looks like all 0s
> sometimes it looks like
> wide characters ie a letter followed by a 0. what am
> I doing wrong. I
> know I had this code working fine a couple of weeks
> ago before my
> Hbridge problems. I had single stepped through all
> of it and then
> pointer was working fine.
>
> volatile const uint8_t * TargetPointer;
>
> #define TARGET_FLFLB 25
> #define TARGET_LFLB 24
> #define ACTION_STRAIGHT 70
> #define ACTION_TURNRIGHT 65
> #define ACTION_STOP 68
>
> const uint8_t Room1[] ={
> ACTION_STRAIGHT,
> TARGET_FLFLB,
> ACTION_TURNRIGHT,
> TARGET_LFLB,
> ACTION_STOP,
> };
>
> uint8_t TempPointer;
>
> TargetPointer = &Room1[0];
> TempPointer = *TargetPointer;
> switch (TempPointer)
> do code based on action
>
>
> --listing
> 17 .Ltext0:
> 18 .global Room1
> 19 .data
> 22 Room1:
> 23 0000 46 .byte 70
> 24 0001 19 .byte 25
> 25 0002 41 .byte 65
> 26 0003 18 .byte 24
> 27 0004 4A .byte 68
>
>
>
>
> Yahoo! Groups Links
>
>
> AVR-Chat-unsubscribe@yahoogroups.com
>
>
>
>
>
>
___________________________________________________________
250MB gratis, Antivirus y Antispam
Correo Yahoo!, el mejor correo web del mundo
http://correo.yahoo.com.ar
Yahoo! Groups LinksMessage
RE: [AVR-Chat] Having trouble debugging a piece of code.
2005-02-08 by wbounce
Attachments
- No local attachments were found for this message.