Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
{
*****************************************************************************
* Name : UNTITLED.BAS *
* Author : [select VIEW...EDITOR OPTIONS] *
* Notice : Copyright (c) 2021 [select VIEW...EDITOR OPTIONS] *
* : All Rights Reserved *
* Date : 7/18/2021 *
* Version : 1.0 *
* Notes : *
* : *
*****************************************************************************
}
// tone generator using CCP compare
Device = 18F43K22
Clock = 64
Include "intosc.bas"
#option DIGITALIO_INIT = true
Include "setdigitalio.bas"
// specify tone library output pin
#option _TONE_OUTPUT_PIN = PORTD.2
Include "tone.bas"
Dim ix As Byte
Dim note As Word
DIM SWT1 AS PORTB.0
DIM SWT2 AS PORTB.1
DIM SWT3 AS PORTB.2
DIM SWT4 AS PORTB.3
DIM SWT5 AS PORTB.4
DIM SWT6 AS PORTB.5
DIM SWT7 AS PORTB.6
DIM SWT8 AS PORTB.7
INPUT(SWT1)
WPUB=255
main:
// init tone library module
tone.init()
IF SWT1=0
THEN
TONE.PLAY(NOTE_F4)
DELAYMS(1000)
tone.stop()
ENDIF
// play A (440) until stop()
tone.play(NOTE_B4)
DelayMS(1000)
tone.stop()
// play all 88 notes for 100msecs each
For ix = 0 To Bound(tone.notes)
note = tone.notes(ix) // current note
tone.play(note, 100)
While(tone.isPlaying())
End While
DelayMS(10) // short delay between notes
Next
While (true)
'IF SWT1=0
'THEN
'TONE.PLAY(NOTE_F4)
'DELAYMS(1000)
'tone.stop()
'ENDIF
End While
Not sure where you found that, but that syntax won't work w/SF unless you have something to define it that way.found this but not sure if it is correct?
intcon2bits.rbpu=0
It does.the setalldigital should disable ADC
{
*****************************************************************************
* Name : UNTITLED.BAS *
* Author : [select VIEW...EDITOR OPTIONS] *
* Notice : Copyright (c) 2021 [select VIEW...EDITOR OPTIONS] *
* : All Rights Reserved *
* Date : 7/18/2021 *
* Version : 1.0 *
* Notes : *
* : *
*****************************************************************************
}
// tone generator using CCP compare
Device = 18F43K22
Clock = 64
Include "intosc.bas"
#option DIGITALIO_INIT = true
Include "setdigitalio.bas"
// specify tone library output pin
#option _TONE_OUTPUT_PIN = PORTD.2
Include "tone.bas"
Dim ix As Byte
Dim note As Word
DIM SWT1 AS PORTB.0
DIM SWT2 AS PORTB.1
DIM SWT3 AS PORTB.2
DIM SWT4 AS PORTB.3
DIM SWT5 AS PORTB.4
DIM SWT6 AS PORTB.5
DIM SWT7 AS PORTB.6
DIM SWT8 AS PORTB.7
' make all of PORTB inputs
TRISB = $FF
' set pullup enable mask for all PORTB pins
WPUB = 255
' and turn on the pullups (RBPU=0)
INTCON2.bits(7) = 0
main:
// init tone library module
tone.init()
// play A (440) until stop()
tone.play(NOTE_B4)
DelayMS(1000)
tone.stop()
// play all 88 notes for 100msecs each
For ix = 0 To Bound(tone.notes)
note = tone.notes(ix) // current note
tone.play(note, 100)
While(tone.isPlaying())
End While
DelayMS(10) // short delay between notes
Next
While (true)
IF SWT1=0 THEN
TONE.PLAY(NOTE_F4)
DELAYMS(1000)
tone.stop()
ENDIF
End While
It is an odd place to put the WPUB control, but that's Microchip for ya.I saw Intcon2 and assumed. ..
It doesn't.However PBADEN is in the Config setup... I don't know whether AllDigital switches it off or not!
Must be a throw back from way back... The Option Reg was king back then..It is an odd place to put the WPUB control, but that's Microchip for ya.
Must be a throw back from way back... The Option Reg was king back then..