Today 13:08
Forum: Absolute Beginners Section
Starter: amod
Views: 0
Replies: 20
Go to last post By: John Drew
Today 10:28
Forum: The Lounge
Starter: pic-ignorant
Views: 0
Replies: 1
Today 01:26
Forum: Proton Studio
Starter: johngb
Views: 0
Replies: 9
+ Reply to Thread
Results 1 to 3 of 3

Thread: MID$ Problem with a PIC18F25K2229 days old

  1. #1
    Junior Member palamont's Avatar
    Join Date
    Dec 2016
    Posts
    10
    Thumbs Up
    Received: 2
    Given: 0
    Total Downloaded
    21.43 MB

    1 Not allowed!

    Question MID$ Problem with a PIC18F25K22

    Hi everybody, I encounter a strange problem : I have a string of 230 characters. This string is divided into 10 segments of 23 characters, with a blank between each segment. I use a uOLED 4DSYSTEM display (uOLED 160G2) to display on each of 6 lines (4,6,8,10,12,14) a different segment of 23 characters. Here is the part of interest of my listing.

    Declare Xtal 64 : OSCCON = $F0 : OSCTUNE = $40 ;horloge interne 64MHz
    TRISB = $00 : TRISC = $20
    Symbol OLED = PORTC.4 : Symbol timetemp = PORTC.5


    Dim i As Byte : Dim numeromp3 As Byte : Dim numtrain As Byte : Dim numtrainajust As Byte : Dim numligne As Byte : Dim numligneajust As Byte

    Dim trains10 As String * 239

    trains10 = "xxxxxxxxxxxxxxxxxxxxxxx ....." ;(239 characters)

    debut:

    For numligne = 0 To 5

    numligneajust = numligne * 2 + 4
    numtrainajust = numligne * 23 + 1

    SerOut OLED,84,[$FF,$E4,$00,numligneajust,$00,$00] : DelayMS 50 ;adress of the line to display the segment n on the OLED

    SerOut OLED,84,[$00,$06,Mid$(trains10,numtrainajust,23),$00] : DelayMS 50 ;string to display on line defined

    Next numligne

    goto debut


    The problem is with the use of the variable "numtrainajust" (beginning of the segment). It's not running, but if I replace "numtrainajust" by a constant, I display the same segment (of course) on all of my six lines.

    So I don't understand why I cannot use a variable instead of a constant. I don't find where is my mistake.

    Thanks for your help !

  2. #2
    Senior Member Stephen Moss's Avatar
    Join Date
    Jan 2006
    Posts
    408
    Thumbs Up
    Received: 28
    Given: 5
    Total Downloaded
    2.08 GB

    0 Not allowed!

    Default Re: MID$ Problem with a PIC18F25K22

    By "not running" do you meant not at all, it does nothing, or that it does something but not do what you want it to do.

    I assume you want to multiple numligneajust by 23, then add 4 to it and to multiply numtrainajust by 23 then add 1 to it, if so then what happens if you change you calculations to...
    numligneajust = (numbligne *2) + 4
    numtrianajust = (numbligne * 23) +1

    thereby ensuring the correct precedence in the calculation.

  3. #3
    Junior Member palamont's Avatar
    Join Date
    Dec 2016
    Posts
    10
    Thumbs Up
    Received: 2
    Given: 0
    Total Downloaded
    21.43 MB

    0 Not allowed!

    Default Re: MID$ Problem with a PIC18F25K22

    Hi Stephen, thanks for your answer, and sorry for my english. You have exactly described what I wanted to do. By "not running", I wanted to say that I had nothing on my display. But, if I replace variables by constants, all is OK. And also, if I do the mathematical operations out of the "SerOut" command, all is OK. That's would want to say it's not possible to insert a math expression inside the "SerOut". So it's the solution I apply. Thanks for your help.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

     

Similar Threads

  1. Mid$ not recognised
    By John Drew in forum Proton Plus Compiler v3
    Replies: 15
    Last Post: 21st March 2018, 09:58
  2. Issue with MID$
    By Frizie in forum Proton Plus Compiler v3
    Replies: 5
    Last Post: 23rd September 2017, 12:59
  3. Problem with MID$ - need help
    By xldaedalus in forum Proton Plus Compiler v3
    Replies: 5
    Last Post: 9th August 2016, 22:28
  4. Pic18F25K22 - PortB enabling Pull up
    By sachindev986 in forum Interrupt Sources
    Replies: 8
    Last Post: 14th June 2014, 21:54
  5. Pic18F25K22 or Pic18F24K22 QFN
    By Tim in forum The Lounge
    Replies: 6
    Last Post: 11th October 2010, 07:29

Members who have read this thread : 56

Actions :  (Set Date)

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts