Announcement

Collapse
No announcement yet.

micro SD card

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Delathouwer
    started a topic micro SD card

    micro SD card

    I'm using the 32PTU module in serial mode.

    I have font's and images on the micro SD card.
    My program starts everytime with a hardware reset.
    Then I read the data from the SD card.
    Just after powering up, no problem.

    But I'm still in the debugging phase, so I do restarts regulary, without removing the power each time.

    I found out that I have to remove and re-insert the SD card each time before a restart.
    If I do not do this, the file mount returns 0x0000.

    Is there a way to avoid this?

    Thanks,

    Patrice

  • astasuleo
    replied
    ok i fixed it: I havent noticed on the manual the 0's i had to put in between the names of the fonts files .DAT $00 .GCI $00

    Inside the uSD i have renamed the FONTs to FONT.DAT and FONT.GCI

    HSEROUT2[$00,$09,"FONT.DAT",$00,"FONT.GCI",$00,$00,$01]

    This is the code in PBP3:

    Code:
    main:
    pause 3000
    high pwrled
    
    HSEROUT2 [$FF,$03] ' MOUNT FILE, this is very imporntat command in here.
    Hserin2 [wait(6),wait(21),wait(75)] 'this is the response from the LCD ACK 5451 or $154B
    Pause 100
    
    HSEROUT2 [$FF,$00,$00,$46]  ' SOUND VOLUME to 70
    Hserin2 [wait(6)]
    Pause 100
    
    HSEROUT2 [$00,$0B,"LASER2.WAV",$00]
    Hserin2 [wait(6),wait(0),wait(65)] ' this is the response from the LCD for the wav file $06 $00 $41
    Pause 200
    
    '-------------------------------------------------------------------------------|
    ' $46,$4f,$4e,$54,$2e,$44,$41,$54 = FONT.DAT (ASCII to HEX)
    ' $46,$4f,$4e,$54,$2e,$47,$43,$49 = FONT.GCI (ASCII to HEX)
    'HSEROUT2[$00,$09,$46,$4f,$4e,$54,$2e,$44,$41,$54,$00,$46,$4f,$4e,$54,$2e,$47,$43,$49,$00,$00,$01] ' SPE serial graphic interface - CALL FONT from SD
    '-------------------------------------------------------------------------------|
    HSEROUT2[$00,$09,"FONT.DAT",$00,"FONT.GCI",$00,$00,$01]
    Hserin2 [wait(6)]
    Pause 200
    
    HSEROUT2[$FF,$E5,$10,$fd] ' SPE serial graphic interface - SET FONT
    Hserin2 [wait(6),wait(0),wait(2)]
    pause 100
    hserout2[$00,$18,"Leonardo",$00] 'SPE serial graphic interface - PUT STRING
    Hserin2 [wait(6)]
    Pause 2000
    HSEROUT2 [$FF,$CD]    ' clear the LCD
    Hserin2  [wait(6)]  
    
    low pwrled
    goto main
    My problem now is:

    The main loop cannot display every time the text. I have put to clear the LCD, and ask to do the same text again and again. But it doent do it for the second time.

    Anyway my problem regarding displaying the FONT from the uSD is solved.

    Code:
    ' -----------------------------------------------------------------------------|  
    '                          [ LCD Initialization ]                              |
    '------------------------------------------------------------------------------|
              ' FIRST TIME BOOTUP: We give plenty of time for tbe LCD '
    
    pause 3000
    HSerout2[$FF,$9E,$00,$01] 'SPE serial graphic interface -SET THE LANDSCAPE R
    Hserin2 [wait(6)]
    HSEROUT2 [$FF,$03] ' MOUNT FILE, this is very imporntat command in here. 
    Hserin2 [wait(6),wait(21),wait(75)] 'this is the response from the LCD ACK 5451 or $154B
    HSEROUT2[$00,$09,"FONT.DAT",$00,"FONT.GCI",$00,$00,$01]
    Hserin2 [wait(6),wait(20),wait(28)]
    '-------------------------------------------------------------------------------|
    ' $46,$4f,$4e,$54,$2e,$44,$41,$54 = FONT.DAT (ASCII to HEX)
    ' $46,$4f,$4e,$54,$2e,$47,$43,$49 = FONT.GCI (ASCII to HEX)
    'HSEROUT2[$00,$09,$46,$4f,$4e,$54,$2e,$44,$41,$54,$00,$46,$4f,$4e,$54,$2e,$47,$43,$49,$00,$00,$01] ' SPE serial graphic interface - CALL FONT from SD
    '-------------------------------------------------------------------------------|
    
    main:
    pause 1000
    high pwrled
    
    HSEROUT2 [$FF,$00,$00,$46]  ' SOUND VOLUME to 70
    Hserin2 [wait(6)]
    HSEROUT2 [$00,$0B,"LASER2.WAV",$00]
    Hserin2 [wait(6),wait(0),wait(65)] ' this is the response from the LCD for the wav file $06 $00 $41 
    pause 100
    
    HSEROUT2[$FF,$E5,$14,$1C] ' SPE serial graphic interface - SET FONT
    Hserin2 [wait(6),wait(0),wait(2)] 
    HSEROUT2[$FF,$E9,$00,$01,$00,$02] ' SPE serial graphic interface - SET Y,X position
    Hserin2 [wait(6)]
    hserout2[$00,$18,"Leonardo Bilalis",$00] 'SPE serial graphic interface - PUT STRING
    Hserin2 [wait(6),wait(0),Wait(16)] 
    Pause 1000
    HSEROUT2 [$FF,$CD]    ' clear the LCD
    Hserin2  [wait(6)]   
    
    low pwrled
    goto main
    Last edited by astasuleo; 29th July 2018, 07:03 AM.

    Leave a comment:


  • astasuleo
    replied
    I commented the wait for the following

    Code:
    HSEROUT2[$00,$09,"FONT.DAT","FONT.GCI",$00,$01] ' SPE serial graphic interface - CALL FONT from SD
    'Hserin2 [wait(6)]
    Pause 200
    
    
    HSEROUT2[$FF,$E5,$14,$1C] ' SPE serial graphic interface - SET FONT
    'Hserin2 [wait(6),wait(0),wait(2)]
    and received

    RX: 06 15 4B
    RX: 06
    RX: 06 00 41
    RX: 06 00 00 15 15 15 15

    which means the 15's are the NAK. so the command i send is not right. Or the LCD didnt get it.

    I also read in the manual for the following:


    Code:
    HSEROUT2[$00,$09,"FONT.DAT","FONT.GCI",$00,$01] ' SPE serial graphic interface - CALL FONT from SD
    HSERIN2 [wait(6)]
    acknowledge
    0x06: ACK byte if successful
    Anything else implies mismatch between command and response.


    Even i changed the ASCII to HEX and dindt work.

    Code:
    ' $46,$4f,$4e,$54,$2e,$44,$41,$54 = FONT.DAT (HEX to ASCII)
    ' $46,$4f,$4e,$54,$2e,$47,$43,$49 = FONT.GCI (HEX to ASCII)
    Code:
    HSEROUT2[$00,$09,$46,$4f,$4e,$54,$2e,$44,$41,$54,$46,$4f,$4e,$54,$2e,$47,$43,$49,$00,$01] ' SPE serial graphic interface - CALL FONT from SD
    HSERIN2 [wait(6)]
    Last edited by astasuleo; 29th July 2018, 06:08 AM.

    Leave a comment:


  • astasuleo
    replied
    I have done the steps more that 100 times.....hehehehe i feel stupid really.

    First i connect the ulcd on the computer via the serial USB PA5ii.

    I open the 4D System software and move to serial SPE.

    Then responds from the LCD are:

    Code:
    gfx_Cls[FFCD ] 0,017 (ACK)
    file_Mount[FF03 ] 0,114 (ACK 5451 0x154B)
    file_LoadImageControl[0009 "FONTST.DAT" "FONTST.GCI" 0001] 0,047 (ACK 5148 0x141C)
    I need to use the hex on my code $14,$1C

    Before that i set the font.


    Code:
    gfx_Cls[FFCD ] 0,017 (ACK)
    file_Mount[FF03 ] 0,114 (ACK 5451 0x154B)
    file_LoadImageControl[0009 "FONTST.DAT" "FONTST.GCI" 0001] 0,047 (ACK 5148 0x141C)
    txt_FontID[FFE5 141C] 0,004 (ACK 2 0x0002)
    Then i test the font.

    Code:
    gfx_Cls[FFCD ] 0,017 (ACK)
    file_Mount[FF03 ] 0,114 (ACK 5451 0x154B)
    file_LoadImageControl[0009 "FONTST.DAT" "FONTST.GCI" 0001] 0,047 (ACK 5148 0x141C)
    txt_FontID[FFE5 141C] 0,004 (ACK 2 0x0002)
    putstr[0018 "TEST FONT"] 0,020 (ACK 9 0x0009)
    and it works. I see the result on the ulcd. So it looks like the font is working via Serial software. So the problem is on my code.

    First of all on the code i mount the file

    Code:
    HSEROUT2 [$FF,$03] ' MOUNT FILE, this is very imporntat command in here. 
    HSERIN2 [wait(6),wait(21),wait(75)] ' this is the response from the LCD ACK 5451 or $154B
    
    following i use the .wav file to see if it is working and what the responses are
    
    HSEROUT2 [$FF,$00,$00,$46]  ' SOUND VOLUME to 70
    HSERIN2 [wait(6)] ' i believe that only this response is back when we set this command. The same response i get from the serial terminal.
    Pause 100
    
    Now problem starts in here with the following command. 
    
    HSEROUT2[$00,$09,"FONTST.DAT","FONTST.GCI",$00,$01] ' SPE serial graphic interface - CALL FONT from SD
    HSERIN2[wait(6),wait(20),wait(28)] ' I think that i should wait for this response as the numbers from the serial 4D systems is ACK 5148 , or HEX 141C

    Leave a comment:


  • astasuleo
    replied
    No im not. I've noticed the program pause on one of the returns.

    I'm about to clear most of the code, make it as simple as possible, and leave only the part of the code for the fonts.

    Then i will check where and why it pauses. Will post back once i have an answer.

    Leave a comment:


  • pauleilio
    replied
    Hi,

    Yes, your font files are correct and work fine.

    Are you able to read all serial returned bytes within your code.

    Best regards

    Paul

    Leave a comment:


  • pauleilio
    replied
    Thanks Yes that's correct, I tend to generalise all graphics files as GCI and DAT,

    I will check these now.

    Leave a comment:


  • astasuleo
    replied
    when i load the fonts to the uSD the files are not .DAT or .GCI, they have different extents like .d01 and .g01

    Click image for larger version  Name:	usd files.png Views:	1 Size:	11.4 KB ID:	64687
    I have attached a .rar file with the files are inside the uSD.

    Leave a comment:


  • pauleilio
    replied
    Hi,

    No that is nothing to worry about, so long as the files have been copied to the uSD card it will be fine. You can send me your .GCI & .DAT file and I will check it for you.

    Best regards

    Paul

    Leave a comment:


  • astasuleo
    replied
    Dear all, i havent manage to use the fonts that i have placed in the uSD.

    actually at VISI when i compile and asked the uSD the following message comes up at the end.

    0 errors
    0 warnings
    1 notice
    No Errors, code size = 21 bytes out of 14400 total
    Initial RAM size = 202 bytes out of 14400 total
    Program will run from ram so total initial RAM size = 223 bytes out of 14400 total

    Do you think that this is a problem?

    Leave a comment:


  • astasuleo
    replied
    Hi Paul,

    dont worry about PIC Basic, i will check that out. i think first i need to see what the response is for every single command and then i will try to solve the issue.

    I will keep you updated.

    Leave a comment:


  • pauleilio
    replied
    Hi,

    It is important that the ACK you are waiting for corresponds to the command sent. Also if the response carries additional bytes it would be best to handle them. Waiting for an ACK is ok but if there is a NACK it wouldn't be detected.

    If for example, you send a command and the response has 3 bytes, first byte is an ACK 0x06, if the second or third byte which would be a return value of the function was also an 0x06, then this would be held in your serial buffer until you next use Hserin2 [wait(6)]. Very quickly it become out of sync and return values wouldn't correspond to the function that was called.

    When loading the font files, we know that 3 bytes are going to be sent back so we need to read all of them, the ACK being the first, if a NACK is received then the next 2 bytes won't arrive so you would have to check for that.

    I will take a look at the PIC Basic you are using to see if I can get a better understanding of how the receiving serial works.

    Best regards

    Paul

    Leave a comment:


  • astasuleo
    replied
    I tried that. Didnt work,

    I tried to load all 8 fonts, one by one at a time, and i was getting the same response 06 15 4B.

    I know that i will find it, but it is driving me crazy.....

    Leave a comment:


  • pauleilio
    replied
    Hi

    The output is perfectly correct.

    RX: 06 15 4B

    06 is the ACK and the next 2 bytes 15, 4B, are the handle of the font you just loaded. This handle will not necessarily be the same as the number you observed in Serial Commander. After you have had the ACK, you will then have to get the extra 2 bytes

    So when you select the font these 2 received bytes need to be in the message you send

    HSEROUT2[$FF,$E5,$15,$4B]

    I hope this helps

    Best regards

    Paul

    Leave a comment:


  • astasuleo
    replied
    Hi Paul,

    first of all, i need to thank you, replying on my questions and problems regarding the Fonts from the uSD.

    Please check the following configuration on the 32PTU when i set the fonts from the uSD using Serial Commander PICASO tool.

    Code:
    gfx_Cls[FFCD ] 0,017 (ACK)
    file_Mount[FF03 ] 0,108 (ACK 5451 0x154B)
    file_LoadImageControl[0009 "FONTST~2.d01" "FONTST~2.g01" 0001] 0,033 (ACK 5148 0x141C)
    file_LoadImageControl[0009 "FONTST~2.d02" "FONTST~2.g02" 0001] 0,038 (ACK 4845 0x12ED)
    file_LoadImageControl[0009 "FONTST~2.d03" "FONTST~2.g03" 0001] 0,037 (ACK 4542 0x11BE)
    file_LoadImageControl[0009 "FONTST~2.d04" "FONTST~2.g04" 0001] 0,039 (ACK 4239 0x108F)
    file_LoadImageControl[0009 "FONTST~2.d05" "FONTST~2.g05" 0001] 0,042 (ACK 3936 0x0F60)
    file_LoadImageControl[0009 "FONTST~2.d06" "FONTST~2.g06" 0001] 0,038 (ACK 3633 0x0E31)
    file_LoadImageControl[0009 "FONTST~2.d07" "FONTST~2.g07" 0001] 0,040 (ACK 3330 0x0D02)
    file_LoadImageControl[0009 "FONTST~2.d08" "FONTST~2.g08" 0001] 0,045 (ACK 3027 0x0BD3)
    txt_FontID[FFE5 0D02] 0,003 (ACK 2 0x0002)
    putstr[0018 "TEST FONT 3330"] 0,028 (ACK 14 0x000E)
    Inside the tool, the test i did works just fine. Then i do the following steps.

    i unplug the Screen from the computer usb PA5 II.

    Install the 32PTU on the testboard.

    And i use the following commands.

    Code:
    HSEROUT2 [$FF,$03] ' MOUNT FILE, this is very imporntat command in here. 
    Hserin2 [wait(6)]
    HSEROUT2[$00,$09,"FONTST~2.d07","FONTST~2.g07",$00,$01] ' SPE serial graphic interface - CALL FONT from SD
    Hserin2 [wait(6)]
    HSEROUT2[$FF,$E5,$0D,$02] ' SPE serial graphic interface - SET FONT
    Hserin2 [wait(6)]
    I have connected the serial terminal to my MCU and the display RX TX.

    The program stops at this point.

    TX: FF 9E 00 01 FF 03 --> this is when i set the LCD in LANDSCAPE R MODE
    RX: 06 00 02 --> the return from the LCD

    TX: 00 09 46 4F 4E 54 53 54 7E 32 2E 64 30 37 46 4F 4E 54 53 54 7E 32 2E 67 30 37 00 01 --> this is when i send the command for the FONTS.
    RX: 06 15 4B --> and this is the return, which 15 i believe is not good as it is the NAK.

    Leave a comment:

Working...
X