Who sees my stupid mistake?


Closed Thread
Results 1 to 28 of 28

Hybrid View

  1. #1
    Join Date
    Feb 2012
    Posts
    57


    Did you find this post helpful? Yes | No

    Default Re: Who sees my stupid mistake?

    I forgot to mention that there are resistors to ground (to keep the input 'low' when no button is pressed) and that the buttons switch to the +5 Volts.

  2. #2
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,614


    Did you find this post helpful? Yes | No

    Default Re: Who sees my stupid mistake?

    16384+12 seems correct for (inverted) 31250 but should it BE inverted and why 16384+3313? (I don't know MIDI...)

    Can you do a standard baudrate like 9600 and verify that data is coming out by using a terminal program?

    The 16F628 does have UART so HSEROUT will work with it. I'd try that but you might need to invert the signal externally.

  3. #3
    Join Date
    Feb 2012
    Posts
    57


    Did you find this post helpful? Yes | No

    Default Re: Who sees my stupid mistake?

    The 16384+12 is correct, I have used that before.
    The calculation is: (1.000.000/Baudrate) - 20 , so 1.000.000 / 31250 = 32 -20 = 12.
    For inverted output set bit 14, = 16384.
    But even with a different baudrate I don't get any output.

    I did a quick test to trace the problem.
    With this code, nothing 'toggles':

    Code:
    Progstart: 
      if PORTB.0 = 1 then 
        Toggle PORTB.6
      endif  
    
    Debounce:
      Pause 20                                       ' ? shorter ?
      If PORTB.0=1 then
        goto Debounce                                ' Button still pressed?
      endif  
      Goto Progstart
    So I suspect the problem is in the line (and similar lines)
    Code:
      If PORTB.0=1 then
    Although I don't see what could be wrong with this...

  4. #4
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    3,172


    Did you find this post helpful? Yes | No

    Default Re: Who sees my stupid mistake?

    If I don't touch programming for a while, I start with blinking a LED to make sure I have the basics working right (config, circuit, programming, etc).
    My Creality Ender 3 S1 Plus is a giant paperweight that can't even be used as a boat anchor, cause I'd be fined for polluting our waterways with electronic devices.

    Not as dumb as yesterday, but stupider than tomorrow!

  5. #5
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    3,172


    Did you find this post helpful? Yes | No

    Default Re: Who sees my stupid mistake?

    Quote Originally Posted by RuudNL View Post
    ...
    If PORTB.0=1
    ...

    You're assuming it can read port B properly.

    I'd start even easier, just blink a LED, nothing else, then build from that.
    My Creality Ender 3 S1 Plus is a giant paperweight that can't even be used as a boat anchor, cause I'd be fined for polluting our waterways with electronic devices.

    Not as dumb as yesterday, but stupider than tomorrow!

  6. #6
    Join Date
    Feb 2012
    Posts
    57


    Did you find this post helpful? Yes | No

    Default Re: Who sees my stupid mistake?

    So nobody can spot a mistake in my sample code?
    Strange, because this line is handled correctly:
    Code:
    If (PORTB.0=1) or (PORTB.1=1) or (PORTB.2=1) or (PORTB.3=1) or (PORTB.4=1) then
    .....

  7. #7
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    3,172


    Did you find this post helpful? Yes | No

    Default Re: Who sees my stupid mistake?

    I pulled out one of my old 16F628 programs from mothballs, only thing I notice, you have no CONFIG statements.


    EDIT: I used this with DEFINE OSC 20

    @ __CONFIG _HS_OSC & _WDT_OFF & _PWRTE_ON & _BODEN_ON & _MCLRE_ON & _LVP_OFF & _CP_OFF
    My Creality Ender 3 S1 Plus is a giant paperweight that can't even be used as a boat anchor, cause I'd be fined for polluting our waterways with electronic devices.

    Not as dumb as yesterday, but stupider than tomorrow!

  8. #8
    Join Date
    Feb 2012
    Posts
    57


    Did you find this post helpful? Yes | No

    Default Re: Who sees my stupid mistake?

    I set the config parameters in the programmer (as usual).
    The values you mentioned are the defaults in my programmer, except the HS mode, that I set manually.
    The point is that everything (almost) works.
    If I create a loop that does nothing else than: serout2 xxx, delay 1000, I get MIDI information every second.
    My main suspect is that the switch(es) are not read correctly in: if PORTB.x =1 then ...
    Last edited by RuudNL; - 2nd March 2024 at 18:04.

Similar Threads

  1. I don't understand my mistake
    By kik1kou in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 31st January 2015, 12:56
  2. Stupid simple question.....
    By chien_fu in forum mel PIC BASIC
    Replies: 18
    Last Post: - 23rd February 2010, 13:21
  3. Stupid question about LCDOUT
    By Glenn in forum mel PIC BASIC Pro
    Replies: 21
    Last Post: - 7th October 2008, 21:37
  4. SERIN2 – SEROUT2 and Manchester mistake.
    By RCtech in forum Serial
    Replies: 8
    Last Post: - 4th September 2007, 22:55
  5. Stupid question
    By Meriachee in forum mel PIC BASIC Pro
    Replies: 15
    Last Post: - 20th July 2007, 05:47

Members who have read this thread : 1

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