Totally agree. Oshonsoft works for C so we'll use that.Maybe trying to force a language change on somebody whose to struggling to understand a language he has used for years, and who has adamantly stated he is unwilling to try something new is a waste of bits.
Maybe trying to force a language change on somebody whose to struggling to understand a language he has used for years, and who has adamantly stated he is unwilling to try something new is a waste of bits.
Hi D,@camerart
This is an aside on block based / visual programming.
There are a number of block programmers developed for folks that learn in visual fashion.
MIT with its Scratch, mBlock, Snap4arduino, Flowcode, Nodered, Visuino, Tuniot.....
Here is an example of what a simple voltage to pulse width converter looks like (just 5 blocks) :
View attachment 142812
You take blocks out of second window, place them in design area (3'rd window),
configure them, and then hit the connect button and mBlock generates C/C++
code and then uses the Arduino IDE programmer to program the target board/part.
The rightmost window is Arduino C/C++ code that mBlock generates from your block
configuration.
I am not advocating this as a way to learn C, rather an adjunct to easily program
simple designs and be able to look at what C/C++ code looks like. Its not optimal
code by any stretch but for simple one off projects fast to get something going.
Some examples :
Pulse Sequence Generator / Smart Timer
Often users, developers, hobbyists need timed and qualified event generators, many resorting to 555 timers and the like. The venerable 555 has had a long run but its limited in accuracy and capability. This approach uses block language to create...www.electro-tech-online.com
GUI Codeless Processor Design
Micro design has for years relied on ASM and C programming and other languages. Often many tasks are fairly simply but these tools were focused and quite a learning curve, especially ASM and C and C++. There are a number of new GUI based tools that essentially take out the "strong typing"...www.edaboard.com Verizon Hotspot Remote Control
Had a problem where I need low cost Network, internet access, at a remote site. Choose to work with Verizon 8800L as it got good reviews for normal attended usage. Motivation was Cell internet only added < $ 20 to the monthly bill. Problems ...www.electro-tech-online.com
Flow code is done with a flowchart like interface (multiple ways, mix and match) :
View attachment 142813
A number of folks experimenting with ChatGPT and other AI programs to generate code. Its a
new world in which complex ideas are getting whittled down into simple code methods. C/C++
was/is a strongly typed language, meaning its exact at how you enter and code with it, not forgiving,
"do it my way or die" type language. These new languages are born out of that and making simple
designs a lot easier. Talking voltmeter above link great example of a complex design reduced to
simple block approach.
C/C++, Python, still the "professional" methods, but block and AI catching up rapidly.
Have some fun, try it out on the simple stuff.
Regards, Dana.
If GPS_String(GPS_LAST) = 0 Then 'GPS_LAST is the last char in the GPS STRING (E/W)
' We are transferring data so look for the $ start character
If PIR1.RCIF = 1 Then
rxirqchar = RCREG 'read the received char, clears RCIF
If rxirqchar = "$" Then
GPS_String(0) = rxirqchar ' store the $ in the GPs string at the start of the string
gps_string_position = 0 ' reset the counter
Else ' we are adding to the string
gps_string_position = gps_string_position + 1 ' point to next location
GPS_String(gps_string_position) = rxirqchar ' and store the data
Endif ' rxirqchar = $
If gps_string_position = GPS_LAST Then ' we are at the end of the buffer
If GPS_String(GPS_LAST) = 0 Then ' Buffer has under run so continue searching for the $
gps_string_position = 0 ' reset the counter
Endif
Endif
Endif
Endif 'GPS_String(GPS_LAST)
Hi T,I think you'll find that's probably a waste of time.
The code he has works "most of the time", so it's likely a matter of finding out what error/timing conditions cause it to fail. That's pretty hard to guess at simulating, and since it involves three different processors that's going to be almost impossible to simulate.
But hey, don't let me burst the bubble.
Hi T,Rearrange the tests so that if RCIF is set you read RCREG.
You also have other bits in PIE1 enabled... are you handling them?
Don't forget to check for OERR.
Hi D,Recommend you try this and then continue.
#define CONFIG1L = 0x00
#define CONFIG1H = 0x28
#define CONFIG2L = 0x1e
#define CONFIG2H = 0x2a
#define CONFIG3L = 0x00
#define CONFIG3H = 0x3f
#define CONFIG4L = 0x80
#define CONFIG4H = 0x00
#define CONFIG5L = 0x0f
#define CONFIG5H = 0xc0
#define CONFIG6L = 0x0f
#define CONFIG6H = 0xe0
#define CONFIG7L = 0x0f
#define CONFIG7H = 0x40
'***************************
#define CLOCK_FREQUENCY = 64
'Define SIMULATION_WAITMS_VALUE = 1
'*******************************************************************
'Example_01
'BPSI, Pic18F46K22, 24/09/2023
'*******************************************************************
'Buffer uart
'*******************************************************************
'********************************************************************
Include "_FuncionesPic18F46K22.bas"
Include "_FuncionesUartRingBuffer.bas"
'Configuración
AllDigital
TRISA = 255
TRISB = 255
TRISD = 255
TRISC = %10111111 'C.6 = Tx, C.7 = Rx
TRISE = %1111
UART1_Init 9600
UART2_Init 9600 '115200
'Call _set_pullup(_pullup_on)
Call _setup_oscillator(_osc_16mhz_hf)
Call _setup_oscillator_mode(_primary_clock)
Call _set_pll4(_pll_on)
Call _interrupts_mode(_disable_priority)
'Call _setup_timer1(_tmr1_internal, _tmr1_div1)
'Call _set_timer1(0xc180)
'Call _timer1(_on)
'Call _enable_interrupts(_int_timer1)
Call _setuprbf(10) 'mSec. Delay Read usart, if read buffer = 0
Call _enable_interrupts(_int_rda)
Dim gps_string(80) As Byte
Dim gps_last As Byte
Dim rxirqchar As Byte
Dim gps_string_position As Byte
gps_string_position = 0
gps_last = 0x0a '??? End trama NMEA.
'$GPRMC,192247.825,A,3643.4983,N,00332.0126,W,0.00,197.95,301204,,*11, CrLf
Call _enable_interrupts(_global_high)
'WaitMs 100
While True 'Loop
'If gps_string(gps_last) = 0 Then 'GPS_LAST is the last char in the GPS STRING (E/W)
' We are transferring data so look for the $ start character
If _buffer > 0 = 1 Then
rxirqchar = _receive() 'RCREG 'read the received char, clears RCIF
Hserout rxirqchar 'Test, output
If rxirqchar = "$" Then
gps_string(0) = rxirqchar ' store the $ in the GPs string at the start of the string
gps_string_position = 0 ' reset the counter
Else ' we are adding to the string
gps_string_position++ ' point to next location
gps_string(gps_string_position) = rxirqchar ' and store the data
Endif ' rxirqchar = $
If rxirqchar = gps_last Then 'we are at the end of the Trama
gps_string(gps_last) = 0x0a 'If end trama NMEA = 0x0a
gps_string_position = 0 ' reset the counter
Hserout "END", CrLf 'Test output
Endif
Endif
'Endif 'GPS_String(GPS_LAST)
Wend
End
'*************************************************
On High Interrupt
Save System
'Control buffer serie
If PIR1.RC1IF = 1 Then
Call _ringbuffer()
Endif
Resume
I'm counting the processor in the GPS as #3Hi T,
Just a note: There are only 2x PICs on each PCB.
C
Hi D,Recommend you try this and then continue.
#define CONFIG1L = 0x00
#define CONFIG1H = 0x28
#define CONFIG2L = 0x1e
#define CONFIG2H = 0x2a
#define CONFIG3L = 0x00
#define CONFIG3H = 0x3f
#define CONFIG4L = 0x80
#define CONFIG4H = 0x00
#define CONFIG5L = 0x0f
#define CONFIG5H = 0xc0
#define CONFIG6L = 0x0f
#define CONFIG6H = 0xe0
#define CONFIG7L = 0x0f
#define CONFIG7H = 0x40
'***************************
#define CLOCK_FREQUENCY = 64
'Define SIMULATION_WAITMS_VALUE = 1
'*******************************************************************
'Example_01
'BPSI, Pic18F46K22, 24/09/2023
'*******************************************************************
'Buffer uart
'*******************************************************************
'********************************************************************
Include "_FuncionesPic18F46K22.bas"
Include "_FuncionesUartRingBuffer.bas"
'Configuración
AllDigital
TRISA = 255
TRISB = 255
TRISD = 255
TRISC = %10111111 'C.6 = Tx, C.7 = Rx
TRISE = %1111
UART1_Init 9600
UART2_Init 9600 '115200
'Call _set_pullup(_pullup_on)
Call _setup_oscillator(_osc_16mhz_hf)
Call _setup_oscillator_mode(_primary_clock)
Call _set_pll4(_pll_on)
Call _interrupts_mode(_disable_priority)
'Call _setup_timer1(_tmr1_internal, _tmr1_div1)
'Call _set_timer1(0xc180)
'Call _timer1(_on)
'Call _enable_interrupts(_int_timer1)
Call _setuprbf(10) 'mSec. Delay Read usart, if read buffer = 0
Call _enable_interrupts(_int_rda)
Dim gps_string(80) As Byte
Dim gps_last As Byte
Dim rxirqchar As Byte
Dim gps_string_position As Byte
gps_string_position = 0
gps_last = 0x0a '??? End trama NMEA.
'$GPRMC,192247.825,A,3643.4983,N,00332.0126,W,0.00,197.95,301204,,*11, CrLf
Call _enable_interrupts(_global_high)
'WaitMs 100
While True 'Loop
'If gps_string(gps_last) = 0 Then 'GPS_LAST is the last char in the GPS STRING (E/W)
' We are transferring data so look for the $ start character
If _buffer > 0 = 1 Then
rxirqchar = _receive() 'RCREG 'read the received char, clears RCIF
Hserout rxirqchar 'Test, output
If rxirqchar = "$" Then
gps_string(0) = rxirqchar ' store the $ in the GPs string at the start of the string
gps_string_position = 0 ' reset the counter
Else ' we are adding to the string
gps_string_position++ ' point to next location
gps_string(gps_string_position) = rxirqchar ' and store the data
Endif ' rxirqchar = $
If rxirqchar = gps_last Then 'we are at the end of the Trama
gps_string(gps_last) = 0x0a 'If end trama NMEA = 0x0a
gps_string_position = 0 ' reset the counter
Hserout "END", CrLf 'Test output
Endif
Endif
'Endif 'GPS_String(GPS_LAST)
Wend
End
'*************************************************
On High Interrupt
Save System
'Control buffer serie
If PIR1.RC1IF = 1 Then
Call _ringbuffer()
Endif
Resume
Hi D,The file containing the ring buffer functions appears to be 100% compatible.
'Include "_FuncionesUartRingBuffer.bas"
Hi D,The "Includes" are simulated but cannot be seen in the tracking.
That's right, if you want to see them you have to paste them into the program.
Hi D,"Do Not Compile Unused" => this has to be enabled in the compiler.
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?