philba said:it suffers from one fatal flaw - it's BASIC.
gramo said:Assembler and C are dieing breeds and higher level programming suits(pic and pc based) are taking over more everyday. There’s no need to re-invent the wheel
What cant you do with Proton+
well, that's a refreshing point of view. too bad it's completely out of sync with reality. You could possibly make an argument that they provide an obsolete programming paradigm but I'd still say you were way off. In terms of what code gets written in which languages, it depends on the microprocessor but it will either be C/C++ or asm in first place and the other in second. any other language is a far far distant noise level 3rd place, probably basic.gramo said:Assembler and C are dieing breeds and higher level programming suits(pic and pc based) are taking over more everyday. There’s no need to re-invent the wheel
What cant you do with Proton+
; WinPicProg BASIC Compiler Version1.91
;
; Device 16F876
LIST P=16F876, W=2, X=ON, R=DEC
#INCLUDE P16F876.INC
__CONFIG 0x393A
;Flags register bit definitions
LEADZ EQU 0x00 ;set to show leading zeros
OverFlow EQU 0x01 ;set for add/sub overflow
Lo EQU 0x05 ;set for I2C normal addressing
Hi EQU 0x06 ;set for I2C extended addressing
Err EQU 0x07 ;set for I2C error
;Pre-defined variables
TEMP1 EQU 32
TEMP2 EQU 33
RESTORE EQU 34
TEMP1_DU EQU 35
TEMP2_DU EQU 36
RESTORE_DU EQU 37
W_DU EQU 38
STATUS_DU EQU 39
Bit_Cntr EQU 40
Xmit_Byte EQU 41
Rcv_Byte EQU 42
LCD_DAT1 EQU 43
Delay_Count EQU 44
_N EQU 44
LCD_DAT2 EQU 45
LCD_DAT3 EQU 46
TEMP_LCD EQU 47
TEMP_LCD2 EQU 48
DELAY1 EQU 49
state EQU 50
pin EQU 51
hiRnd EQU 52
lowRnd EQU 53
Acc1L EQU 54
Acc1H EQU 55
Acc2L EQU 56
Acc2H EQU 57
Acc3L EQU 58
Acc3H EQU 59
Flags EQU 60
TenK EQU 61
Thou EQU 62
Hund EQU 63
Tens EQU 64
Ones EQU 65
Adr_Lo EQU 66
Adr_Hi EQU 67
Chip_Adr EQU 68
Data_Page EQU 69
; Macros
fcall macro subroutine_name
local here
lcall subroutine_name
pagesel here
here:
endm
ORG 0x0000
NOP ;for bootloader compatibility
NOP
NOP
GOTO _START1
ORG 0x1800
#INCLUDE MATHS.INC
#INCLUDE HANDLERS.INC
ORG 0x0010
_START1
CLRF RESTORE
CLRF Flags
BCF Flags, LEADZ
BANKSEL ADCON1
MOVLW 0x06
MOVWF ADCON1
BANKSEL PORTA
; Dim A,I,B
VAR2 EQU 70;A
VAR4 EQU 72;I
VAR6 EQU 74;B
; Define PortA=%11111111
BANKSEL TRISA
MOVLW 255
MOVWF TRISA
BANKSEL PORTA
; Define PortC=%00000000
BANKSEL TRISC
MOVLW 0
MOVWF TRISC
BANKSEL PORTC
; Define PortB=%00000000
BANKSEL TRISB
MOVLW 0
MOVWF TRISB
BANKSEL PORTB
; Set(ADC_Channel=0)
MOVF ADCON0,W
ANDLW 0xC5
IORLW 0x00
MOVWF ADCON0
; Set(ADC_Config=14)
MOVLW 0x0E
BANKSEL ADCON1
MOVWF ADCON1
BSF ADCON1,ADFM
BANKSEL ADCON0
; Set(ADC_Clock_Source=CLOCK/8)
BCF ADCON0,ADCS1
BSF ADCON0,ADCS0
; I=0
MOVLW 0
MOVWF VAR4+1
MOVLW 0
MOVWF VAR4
; OUTC(0)
MOVLW 0
MOVWF PORTC
; OUTB(0)
MOVLW 0
MOVWF PORTB
; Loop:
LAB1:
; Start(ADC)
BSF ADCON0, ADON
BSF ADCON0, GO_DONE
BTFSC ADCON0, GO_DONE
GOTO $-1
; Delayms(255)
MOVLW 0
MOVWF Acc1H
MOVLW 255
MOVWF Acc1L
fcall _DELAYMS
; Delayms(255)
MOVLW 0
MOVWF Acc1H
MOVLW 255
MOVWF Acc1L
fcall _DELAYMS
; Delayms(255)
MOVLW 0
MOVWF Acc1H
MOVLW 255
MOVWF Acc1L
fcall _DELAYMS
; Delayms(255)
MOVLW 0
MOVWF Acc1H
MOVLW 255
MOVWF Acc1L
fcall _DELAYMS
; A=ADC_ResultL
BANKSEL ADRESL
MOVF ADRESL,W
BANKSEL ADRESH
CLRF Acc1H
MOVWF VAR2
MOVF Acc1H, W
MOVWF VAR2+1
; B=ADC_ResultH
MOVF ADRESH,W
CLRF Acc1H
MOVWF VAR6
MOVF Acc1H, W
MOVWF VAR6+1
; OUTC(B)
MOVF VAR6,W
MOVWF PORTC
; OUTB(A)
MOVF VAR2,W
MOVWF PORTB
; Goto Loop
GOTO LAB1
; end
CLRWDT
SLEEP
END
;
;Number of variables used:74 out of 127
grim said:unless i have missed something do any of the basic/c languages support every pic out there, and keep up with microchip developments like mpasm does?
so i want a high level code, that supports every chip i could want, produces fast neat code, and is avaliable as sharewarenot much to ask, surely
Dim Number1 as Float
Dim Number2 as Float
Dim Result as Float
Number1 = 1000 / 500.23
Number1 = (Number1 - 0.5) * 10
Number2 = Number1 / 2.551 * 10000
Result = (Number1 + Number2) / 2.597
Print At 1,1, Dec Result ' Display data on a LCD
Value = ADIN 0 ' Perform an ADC on channel 0
EWRITE 00,[Value] ' Write to eeprom address 0
Value = EREAD 00 ' Read from address 0
For X = 1 to 10, Step 2 ' Fill an array with random data
Storage[X] = Random ' Random will return a random number between 0-65535
Next X
Repeat ' Create a looping condition
X = X +1
Until PORTA.1 = 1 And X = 10 ' Exit only if porta.1 = 1 and x=10
Thousands = Dig Value,3 ' Extract the 4th digit(thousands) from the value
Delayms 10000 ' Create some delays
Delayus 1 '
HPWM CCP1, 128, 2000 ' Create a PWM with duty of 50% and 2Khz
HPWM CCP2, 64, 25000 ' Create a PWM with duty of 25% and 25Khz
PULSOUT PORTB.0, 100, High ' Send a high pulse for 10ms on PORTB.0
Value = COUNTER PORTB.1, 100 ' Count every pulse on PORTB.1 for 100ms
SERVO Pin , Value ' Tell a servo to turn to an exact position
BStart ' Send the start command on I2C
BusOut %10100010,00,[Value.HighByte] ' Send the word to the eeprom
BStop
Delayms 5
BStart ' Send the start command on I2C
BusOut %10100010,00,[Value.LowByte] ' Send the word to the eeprom
BStop
SEROUT PORTA.0 , T9600 , [ DEC Value ] ' Send data via software USART
SHOUT DTA , CLK , MSBFIRST , [Value] ' Send data via SPI
OWRITE DQ, 1,[$55,Address_L, Address_H,Value, Value] ' Via 1 wire protocol
gramo said:Assembler and C are dieing breeds and higher level programming suits(pic and pc based) are taking over more everyday. There’s no need to re-invent the wheel
What cant you do with Proton+
Nigel Goodwin said:As for BASIC compilers that show you the assembler code, here's the assembly listing produced by my WinPicProgB BASIC compiler/programmer, it inserts the basic lines as comments in the assembler source code.
mramos1 said:And where do I download this WinPicProgB BASIC compiler? I will bite?
MPLABS code too??
Nigel Goodwin said:Sorry, you don't, it's not been released
From MicroChip, a free download.
mramos1 said:Honestly, PICbasic with a proper IF THEN ELSE ENDIF and maybe ADC command would be all I would ever need. I have no problem with a .ASM and .ASMEND as lond as I can get to the variables.
There is also an advanced version of IF/THEN available, IF/THEN/ELSE/ENDIF, this allows more advanced program structures to be written, you may have multiple lines between the THEN, ELSE and ENDIF sections.
Device 16F876
Dim A,I,B
Define PortA=%11111111
Define PortC=%00000000
Define PortB=%00000000
Set(ADC_Channel=0) 'will use pin RA0 for AD input
Set(ADC_Config=14) 'option 14 only A0 is used
Set(ADC_Clock_Source=CLOCK/8)
I=0
OUTC(0) 'clear OP display
OUTB(0)
Loop: Start(ADC)
Delayms(255)
Delayms(255)
Delayms(255)
Delayms(255)
A=ADC_ResultL 'get results
B=ADC_ResultH
OUTC(B) 'display them
OUTB(A)
Goto Loop
end
Nigel Goodwin said:This is how to use the ADC!
Code:Device 16F876 Dim A,I,B Define PortA=%11111111 Define PortC=%00000000 Define PortB=%00000000 Set(ADC_Channel=0) 'will use pin RA0 for AD input Set(ADC_Config=14) 'option 14 only A0 is used Set(ADC_Clock_Source=CLOCK/8) I=0 OUTC(0) 'clear OP display OUTB(0) Loop: Start(ADC) Delayms(255) Delayms(255) Delayms(255) Delayms(255) A=ADC_ResultL 'get results B=ADC_ResultH OUTC(B) 'display them OUTB(A) Goto Loop end
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?