|
|
View previous topic :: View next topic |
Author |
Message |
neochrome32
Joined: 09 Jun 2013 Posts: 153
|
problem with HEX reading out wrong [Solved] |
Posted: Sat Aug 10, 2013 12:09 am |
|
|
I am using Compiler 4.130 with a PIC24HJ128GP502
printf (" %02X", data[i]); is the command i want
but its printing out FF80 instead of the 80
here is the function
Code: |
void PrintData(int8 *data, long len){
long i;
long j;
long k;
int8 step1;
//int8 step2;
printf ("Showing Block Length: %lx [%lu byte(s)]\n", len,len);
j = 0;
step1=0;
//step2=0;
for (i = 0; i < len; i++){
printf (" %02X", data[i]);
if((i%8)==7)
putc(' ');
if (j >= 31) {
printf (" | ");
for (k = (i - 31); k <= i; k++) {
if (! isalnum (data[k])) printf (".");
else printf ("%c", (int8)data[k]);
if((k%8)==7)
putc(' ');
}
printf ("\r\n");
j = 0;
} else {
j++;
}
}
putc('\n');
}
|
I am tired so I'm not thinking at all correctly. I'm aware that this chip is 16bit and its causing all sorts of hassle with the FAT32 code too. |
|
|
neochrome32
Joined: 09 Jun 2013 Posts: 153
|
[fixed it] |
Posted: Sat Aug 10, 2013 1:10 am |
|
|
u had to UNSIGN the char!
i thought char was already an uninsigned thing... oh well |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19549
|
|
Posted: Sat Aug 10, 2013 2:50 am |
|
|
This is why several posters (myself included), prefer to include 'stdint.h', and be explicit, using uint8_t etc..
It changes, with ANSI mode, and the default int size changes with PCD. Put together, these are 'waiting to catch you'....
Best Wishes |
|
|
neochrome32
Joined: 09 Jun 2013 Posts: 153
|
|
Posted: Sat Aug 10, 2013 2:17 pm |
|
|
Yeah i found that these chips seem to be different..
turns out i have ALOT still to learn :(
though its fun, but maybe i should have waited a bit more before attempting anythine SDCARD
(tho it works now... i cant figure out how to dertermine the sector stepping)
example my 2GIG memcard you have to jump, 0, 512, 1024.... so on
in 8 did, you only have to jump 0, 1, 2... and that goes to the right sector... need to know how to determine if i should do this or not :(
[edit]
ALSO, im not entirely sure, but on the PIC24H
int8 is the same ans signed int i take it? since the INT8 is the same as Unsigned INT8 on a regulare PIC18F? |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19549
|
|
Posted: Sat Aug 10, 2013 2:29 pm |
|
|
Do a search for SDHC.
Over 2G, a card is 99% likely to be formatted SDHC, not SD (there are a few 'transitory' cards).
The standard drivers only support SD.
In all honesty, unless your time is of low value, buy the Brush electronics drivers. These support SD, and SDHC, handle FAT12, 15, & 32. I wrote my own modified ones for SD, then decided it was much easier to buy these....
Best Wishes |
|
|
neochrome32
Joined: 09 Jun 2013 Posts: 153
|
|
Posted: Sat Aug 10, 2013 2:42 pm |
|
|
LOL to be honest, I like learning these things and CHEAP is my game... hahah
So from the specs here, SDHC are formatted and function as
0 = sector 0, 1 = sector 1, 2 = sector 2 and so on...
the standard SD (cheaper and simpler)
0 = sector 0, 512 = sector 1, 1024 = sector 2..
it reads as though this is standard across all cards SDHC and the like.
so i just got to figure out HOW to determine the sector size and type of card... CMD58 is returning TURD :( |
|
|
|
|
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 vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|