when i use KS0108 , the micro reseted ??

21 views
Skip to first unread message

majid ebru

unread,
Jul 18, 2021, 8:39:31 PM7/18/21
to jallib

Hi again
 i use this code :

include 18f4520
pragma target clock   8_000_000                   -- Fosc
pragma target OSC     hs
pragma target LVP     disabled
--
-- GRAPHIC_LCD IO definition ------------------------
var byte GLCD_DATAPRT     is portD
var byte GLCD_DATAPRT_DIR is portD_direction

alias GLCD_CS1 is pin_b0
alias GLCD_CS2 is pin_b1
alias GLCD_RST is pin_b2
alias GLCD_RW  is pin_c1
alias GLCD_E   is pin_b3
alias GLCD_DI  is pin_b4
--
alias GLCD_CS1_DIRECTION is pin_b0_direction
alias GLCD_CS2_DIRECTION is pin_b1_direction
alias GLCD_RST_DIRECTION is pin_b2_direction
alias GLCD_RW_DIRECTION  is pin_c1_direction
alias GLCD_E_DIRECTION   is pin_b3_direction
alias GLCD_DI_DIRECTION  is pin_b4_direction

const GLCD_CLIPPING = TRUE                         -- enable clipping (of ellipse)

enable_digital_io()                                -- all pins digital I/O
include delay
include math
include print
include glcd_5x7_font
include glcd_6x8_font
include glcd_font                                  -- common font stuff
glcd_font_use(FONT_5X7)                            -- activate font

include glcd_ks0108                                -- glcd device dependent library
include glcd_common                                -- device independent glcd library

glcd_init()                                        -- initialize display

---------------------------
glcd_clear_screen()
var word n = 0
var byte i = 40
--
--
glcd_box(0,0,127,63)
--
--
forever loop

end loop

----------------------
glcd_box(0,0,127,63)

this is code doesn't work??

but if i change that to glcd_box(0,0,127,55) < this works correctly ?

can somebody help me ??


Rob CJ

unread,
Jul 19, 2021, 1:07:09 PM7/19/21
to jal...@googlegroups.com
Hi Majid,

I cannot see anything wrong with your code. Did you try to make a box by writing 4 lines to the screen to see if that works OK? It is not a solution but a test to see if you can write the lines on 'the edges' of the display.

Kind regards,

Rob


Van: jal...@googlegroups.com <jal...@googlegroups.com> namens majid ebru <majid...@gmail.com>
Verzonden: maandag 19 juli 2021 02:39
Aan: jallib <jal...@googlegroups.com>
Onderwerp: [jallib] when i use KS0108 , the micro reseted ??
 
--
You received this message because you are subscribed to the Google Groups "jallib" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jallib+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jallib/b05ea9ea-8601-44f3-b3b3-d315da0df328n%40googlegroups.com.

majid ebru

unread,
Jul 20, 2021, 3:12:30 PM7/20/21
to jallib
Hi
i use glcd_line but it doesn't work correctly?


include 18f4520
pragma target clock   8_000_000                   -- Fosc
pragma target OSC     hs
pragma target LVP     disabled
--
-- GRAPHIC_LCD IO definition ------------------------
var byte GLCD_DATAPRT     is portD
var byte GLCD_DATAPRT_DIR is portD_direction

alias GLCD_CS1 is pin_b0
alias GLCD_CS2 is pin_b1
alias GLCD_RST is pin_b2
alias GLCD_RW  is pin_c1
alias GLCD_E   is pin_b3
alias GLCD_DI  is pin_b4
--
alias GLCD_CS1_DIRECTION is pin_b0_direction
alias GLCD_CS2_DIRECTION is pin_b1_direction
alias GLCD_RST_DIRECTION is pin_b2_direction
alias GLCD_RW_DIRECTION  is pin_c1_direction
alias GLCD_E_DIRECTION   is pin_b3_direction
alias GLCD_DI_DIRECTION  is pin_b4_direction

const GLCD_CLIPPING = false                         -- enable clipping (of ellipse)


enable_digital_io()                                -- all pins digital I/O

include delay
include math
include print
include glcd_5x7_font
include glcd_6x8_font
include glcd_font                                  -- common font stuff
glcd_font_use(FONT_5X7)                            -- activate font

include glcd_ks0108                                -- glcd device dependent library
include glcd_common                                -- device independent glcd library

glcd_init()                                        -- initialize display

---------------------------
glcd_clear_screen()
forever loop
    if n < 10000 then block
        n = n + 1
     end block
    else block
        n = 0
        FlashLED1 = ! FlashLED1
        if(FlashLED1)then block
--------------------------------------------------
           glcd_write_pixel(60,i)
            glcd_line(0,i,127,i)
          glcd_char_goto(50,30)
          print_word_dec(glcd,i)
--------------------------------------------------
          i = i + 1
      end block end if
    end block end if
end loop
------------------------------------------------------------------------------------

only draw 56 (0~55) lines ?!?

majid ebru

unread,
Jul 21, 2021, 1:54:17 AM7/21/21
to jallib

I think(feel) zero division happens in micro

majid ebru

unread,
Jul 21, 2021, 1:56:19 AM7/21/21
to jallib
I think(feel) zero division happens in micro
Maybe in the file glcd_common or file glcd_ks0108 , i don't know

Rob CJ

unread,
Jul 21, 2021, 12:50:31 PM7/21/21
to jal...@googlegroups.com
Hi Majid,

Can you simply the program to write once the following:

glcd_line(0,0,127,0)
glcd_line(0,0,0,63)
glcd_line(127,0,127,63)
glcd_line(0,63,127,63)

Do you get a box?

Kind regards,

Rob


Verzonden: woensdag 21 juli 2021 07:56
Aan: jallib <jal...@googlegroups.com>
Onderwerp: Re: [jallib] when i use KS0108 , the micro reseted ??
 

majid ebru

unread,
Jul 22, 2021, 5:19:50 AM7/22/21
to jallib
Hi Ron

I wrote these codes and micro didn't work
I should change 63 to 55 .
Also I can't write string in position y=55
I can draw line 55 and write text in 48 ?!?

Rob CJ

unread,
Jul 22, 2021, 1:17:44 PM7/22/21
to jallib
Hi Majid,

I do not have your display but I can test it on a Nokia display. It does not use your driver but is uses a part of the glcd_common. Maybe there is an issue there.

In the following video you can see what I tested bu I did not test a square exactly around the edges:
Demo program showing the functionality of the PIC JAL library of the Nokia 5110 display.Jallib can be found at: http://justanotherlanguage.org/


I will give it a try this weekend.

Kind regards,
Rob


Verzonden: donderdag 22 juli 2021 11:19

Rob CJ

unread,
Jul 22, 2021, 3:50:57 PM7/22/21
to jal...@googlegroups.com
Hi Majid,

I did a test with the Nokia 5110 display which has a resolution of 84 x 48 pixels.

Since you can only write to this Nokia display the JAL driver for this display keeps a pixel cache which is first updated with the pixel data and then written to the display so it is different from yours. In your case the driver reads data from the display, updates that and writes it back.

With the following code I was able to write a box at the edges of the display (the delays are just to see it working) for the Nokia display:

   glcd_clear_cache()
   nokia_clear_screen()
   delay_1s(1)
   glcd_box(0,0,83,47)
   glcd_cache_update()
   delay_1s(3)

In the libraries the glcd_box function calls glcd_line function which in the end calls the glcd_write_pixel function. The first two functions are in glcd_common.jal but the glcd_write_pixel_function is device specific and is so part of the Nokia library and part of the KS0108 library.

So if something is wrong then I assume it must be in the pixel function. So what you could do is test if you can write pixels in all corners of the display.

I used this code for the Nokia display and I see a pixel in each corner so that works correctly.

   glcd_clear_cache()
   nokia_clear_screen()
   delay_1s(1)
   glcd_write_pixel(0,0)
   glcd_write_pixel(83,0)
   glcd_write_pixel(0,47)
   glcd_write_pixel(83,47)
   glcd_cache_update()
   delay_1s(3)

Can you test if you can write these pixels too using the resolution of your display?

The total program is attached in the zipfile.

Kind regards,

Rob


Van: jal...@googlegroups.com <jal...@googlegroups.com> namens Rob CJ <rob...@hotmail.com>
Verzonden: donderdag 22 juli 2021 19:17
16f1825_nokia_5110_box_test.zip

majid ebru

unread,
Jul 25, 2021, 2:54:43 PM7/25/21
to jallib

Hi Rob
Thank you very much.

I tested this program on bread broad and when I change my board in pcb board , everything is ok.

I don't know what my wrong was?!

But now, everything is good.

Thank you Rob.

Kind regards.
Reply all
Reply to author
Forward
0 new messages