Going nuts!!!! (not PICAXE)

bag57pipe

New Member
Hi I know this is a picaxe site but I'm at my whits end and this is probably the only place I know where I will get an answer that mere mortals such as myself will understand. I usually use picaxe (dead easy) but occcasionaly dabble in projects that require assembler, there lies the problem. I have been trying to get to grips with the microchip programming software for about 15 years the format keeps changing the chips get more complex the programing suit gets bigger the help files are crap it will no longer accept straight Hex files I don't know why but it does not like text edited Hex files I have had run time errors java errors the PC just choked errors you name it. As an example I should be able to access the target power settings for the pick kit II/III from MPLABX the tab shown on microchips help page does not exist. Most info on the web is either inaccurate out of date or the author uses an ancient software package that is not available anymore and not fully compatable with MPASM or MPLAB I can usually fault find OK but when there is potentially more than one problem where do you start.
I have tried the old go away leave it come back later (usually much later) it does not help I'm so far gone I don't think I would recognise the answer if it jumped up and bit me!
In short:
1) is there a book that is not 200 years out of date (no 16C84's mentioned) and does not go from blink L.E.D to lets refit the space shuttle in two pages.
2) A current source of wisdome on the net that would cover most of the above problems without being spread over 200 badly laid out pages full of dead links (as is with microchip).
3)Does anybody do training courses for Idiots that don't run into thousands of pounds.
I have been searching for some time I did try contacting a maker group but they were all AVR fans and not very freindly.
 

Buzby

Senior Member
Look at this : https://www.youtube.com/watch?v=C1on-LaIsCA

Jump to about 5:45 to see him programme an 18 year old chunk of code into a modern PIC with MPLABX, straight from the original ASM file.

( This guy has loads of good stuff to say, but he's too slow getting to the point, and keeps going off track. )

If you do find a good source of help with MPLABX please let me know, as I will need it soon. ( Not leaving PICAXE, but have a need that must be assembled. )

Cheers,

Buzby
 

tmfkam

Senior Member
I have been trying to learn Assembly programming for the PIC since 1995. I still can't get my head round it! Especially not using any of the MPLAB products (bar one).

Having the need to progress in terms of outright speed for a (then) new job spurred me on to look at alternatives. I spent some time considering the MikroE products, particularly the Pascal compiler as I am (or was) very familiar with Borland's Delphi (for Windows) which implements the Pascal language. Various other products crossed my radar, I gave demos a try for all sorts of environments, but none really gelled with me. Until I discovered Great Cow Basic.

GCB takes a Basic program and compiles it fully (first into .asm) to a .hex file that can be programmed into a native PIC, directly. For programming I use the MPLAB IPE (Integrated Programming Environment) which has to be downloaded as part of the full MPLAB installer, but can be installed by selecting only the IPE when running the installer. The IPE allows selection of all required elements to program the PIC using a PicKit (or clone) as well as reading back the contents of any connected PIC assuming the protection bit isn't set. GCB can programatically the frequency, oscillator type, protection bits and so on from within the source code which makes for a much more 'PicAxe' type plug 'n' play feel to programming. GCB Basic has a few syntactical differences to PicAxe Basic, so a PicAxe program can't be copied and pasted into a GCB program, but if you do try that, it isn't too onerous to work through the program and make the changes as needed. Not only that, but if you have existing projects using 14M2 and 20M2 devices, PIC 16F1825 and 16F1829 are virtually pin compatible drop in replacements.

I still love PicAxe. A new engineer has started work for us and I'm encouraging him to learn programming, using PicAxe as I think PE6 (and PE5) with their simulators and some of the hardware project kits are fabulous learning tools. Possibly the best I've seen. I worked in a Technical College for five years and taught some lessons on programming to the Students and would have much preferred to have used PicAxe to the Matrix products. The one downside to PicAxe is the reduction in speed caused by the interpreter.
 

Rick100

Senior Member
Hello bag57pipe,

It took me a couple of attempts to get started with Pic assy. Which chip are you trying to use? The older chips like the 16F84 are easier to learn assy language on because they have fewer peripherals. Pic assy gets very tedious for any project over 1K IMO. It can be fun for small programs though. I always liked MPLAB 8. It seems like they got it working pretty well before they went to MPLAB X. I had a book called "Easy Pic'n" that helped me with some of the basics but it is dated. People on other forums, even ones aimed at beginners, usually aren't as nice as they are here.

Look at this : https://www.youtube.com/watch?v=C1on-LaIsCA

Jump to about 5:45 to see him programme an 18 year old chunk of code into a modern PIC with MPLABX, straight from the original ASM file.
I just tried this with a program dated 2007 for a 16F84A. I had installed MPLABX on this computer but never use it. It went just like Dave's video until I built the project. I threw out errors on all the symbols in the include file for the device. I tracked the include file down and all the symbols were in upper case. My program had them in lower case. I remembered that I used to turn off case sensitivity and set the default radix to decimal on all my projects. I found the project properties and turned off case sensitivity for the assembler. Then I got a successful build. MPLAB X won't recognize my Pickit 2 though. :( It seems like EEVBlog did another video where they wasted several hours trying to get a Pickit to work. Something about a firmware update. I'll have to track that video down.

Good luck,
Rick
 

Buzby

Senior Member
.... Then I got a successful build. MPLAB X won't recognize my Pickit 2 though. :( It seems like EEVBlog did another video where they wasted several hours trying to get a Pickit to work. Something about a firmware update.
It's this type of problem that puts me off investing time in something other than PICAXE. One of the great points of PICAXE is that it just works. No faffing about trying to match compilers with assemblers, and then finding some hardware that will get it into your chip. ( The last time I did PIC assembler I used David Tait's parallel port 'quick and dirty' programmer. It's still available on here : http://www.nomad.ee/PIC/links.shtml but I don't know if it's of any use with a modern PIC. )

There is NOTHING that is as easy to use as PICAXE !.

Cheers,

Buzby
 

Janne

Senior Member
EEVblog also made a video of idiot assembler programmers.. :) Check it out if you want to see another rant video.
 

fernando_g

Senior Member
1) is there a book that is not 200 years out of date (no 16C84's mentioned) and does not go from blink L.E.D to lets refit the space shuttle in two pages.
Bob Pease had a similar rant about introductory electronics courses, it went something like this:
Chapter 1 was electron flow and current,
Chapter 2 was the diode,
Chapter 3 was the triode,
Chapter 4 was the pentode,
Chapter 5 was "A 10-tube superheterodine single-sideband receiver with AGC, selectable bandwidth and a beat frequency oscillator"
 
Last edited:

bag57pipe

New Member
EEVblog also made a video of idiot assembler programmers.. :) Check it out if you want to see another rant video.
I have seen a few of the EEV blogs he gets pretty wound up I know how he feels. Oddly enough some of the mplab stuff finally made sense . The latest mplabx update poped up when I had a go today, fool that I am I installed it my nice new'sh windows 10 bombed and had to reinstall the whole lot. Who was the nut job who thought having megabytes of help file on line was a good idea my PC can't cope. In the end I installed MPLAB8. I have difficulty reading text such as c:1/lostdirectory\confused/ys
I have difficulty differentiating between d-b \-/ (-) a-8 (why this one I have no idea) which is why paradoxically I prefer assembler to c++. Assembler is good for tight timing loops my interests include sound generation. The programming editor did support assembler not the best compiler but it kept the basic code as comments so that it could written in basic debugged then tweaked in assembler. I made an 8 hole bag pipe canter with 2 cd4011's for touch switches and a 12F629 decoding that way the notes were generated by bit banging the tuning was a bit off but anybody who plays a Northumbrian small pipe in tune is probably delusional. Thanks to all who replied the info came in handy I'm off to see how well I can persuade a Picaxe to generate hellschreiber.
 

stan74

Senior Member
re tmfkam comment. The GCB guys are having probs with some 18f pics and the microchip docs pll osc speed info is incorrect for bits set so it's trial error testing cos the dev guys are fussy all pics and avr work. It shows with incorrect baud rate using terminal. Microchip got complicated since me using notepad,mpasm and programmer flash hex.
I used picaxe happily until I got a ssd1306 graphic lcd. No support but forum helped me lots but picaxe is too slow for drawing lines ie lots of calculated pixels.
Forget pic asm, GCB generated asm is optimised and better than I could write. Get a uno for £3 (just plug in usb lead) and try GCB cos it's free
 

bag57pipe

New Member
Bob Pease had a similar rant about introductory electronics courses, it went something like this:
Chapter 1 was electron flow and current,
Chapter 2 was the diode,
Chapter 3 was the triode,
Chapter 4 was the pentode,
Chapter 5 was "A 10-tube superheterodine single-sideband receiver with AGC, selectable bandwidth and a beat frequency oscillator"
I'm getting all nostalgic I remember valves, and to a teenager as I was at the time most English electronics books were so boring you could lose the will to live reading them. The American Foulsham Tab books were easy and quite inventive but the language was embarrassing!
The great thing about Picaxe is it takes very little effort to create something it will probably never replace my favourite chip the venerable NE555 but it would take a lot of them to do the things a Picaxe can! I think I have just about talked myself out of using assembler.
 

bag57pipe

New Member
re tmfkam comment. The GCB guys are having probs with some 18f pics and the microchip docs pll osc speed info is incorrect for bits set so it's trial error testing cos the dev guys are fussy all pics and avr work. It shows with incorrect baud rate using terminal. Microchip got complicated since me using notepad,mpasm and programmer flash hex.
I used picaxe happily until I got a ssd1306 graphic lcd. No support but forum helped me lots but picaxe is too slow for drawing lines ie lots of calculated pixels.
Forget pic asm, GCB generated asm is optimised and better than I could write. Get a uno for £3 (just plug in usb lead) and try GCB cos it's free
I have an amicus 18 board with the same sort from layout as the picaxe 28x shield and the a****o (sh-sh no AVR) that is compiled basic and a micromite 28pin board running interpreted basic the both run much faster than Picaxe but the time invested in learning the lingo is much more. It's a shame you can't poke few lines of hex into a Picaxe like you could in the 80's on them old computers even an 08M2 has enough ram and uncommited seldom for the amount of code I have in mind.
 

bag57pipe

New Member
I have an amicus 18 board with the same sort from layout as the picaxe 28x shield and the a****o (sh-sh no AVR) that is compiled basic and a micromite 28pin board running interpreted basic the both run much faster than Picaxe but the time invested in learning the lingo is much more. It's a shame you can't poke few lines of hex into a Picaxe like you could in the 80's on them old computers even an 08M2 has enough ram and uncommited seldom for the amount of code I have in mind.
The spell checker got me again I meant eeprom not seldom, somebody I know sent an e mail to the chief executive and it changed the exec's name to something offensive (it was OK he knew everyone hated him !).
 

stan74

Senior Member
If I try to program on rasp pi I use freebasic. It's easier and faster than using python.
You don't forget basic once you've learnt it...unlike assembler. Applying basic to ucontrollers is a bit strange but works fine in reality.
I wouldn't advise learning assembler when you can use basic. Here's basic 1ms interrupt code
Code:
#chip 18f25k22,32
#config osc = int
dir portb.7 out
 ' TMR0_Initialize() '
    InitTimer0(Osc, (TMR0_FOSC4 + PRE0_32) , POST0_1)
    SetTimer(0, 0xF900) ' Preload Count for 1ms '
    StartTimer 0
  ' Add a handler for the interrupt '
  On Interrupt Timer0Overflow Call TMR0_ISR

do
loop


  Sub TMR0_ISR()
    portb.7 = not portb.7
;
   SetTimer(0, 0xFA00) ' reset count for 1ms adj for isr time'
  End Sub

End
Now here's the basic and the assembler equivalent
 LIST p=18F25K22, r=DEC
#include <P18F25K22.inc>
 CONFIG LVP = OFF, MCLRE = INTMCLR, WDTEN = OFF, FOSC = INTIO67

;********************************************************************************

;Set aside memory locations for variables
SAVESYSTEMP1  EQU 1
SYSBSR  EQU 2
SYSSTATUS EQU 15
SYSTEMP1  EQU 3
SYSW  EQU 14
TMRNUMBER EQU 4
TMRPOST EQU 5
TMRPRES EQU 6
TMRSOURCE EQU 7
TMRVALUE  EQU 8
TMRVALUE_H  EQU 9

;********************************************************************************

;Vectors
  ORG 0
  goto  BASPROGRAMSTART
  ORG 8
  bra INTERRUPT

;********************************************************************************

;Start of program memory page 0
  ORG 12
BASPROGRAMSTART
;Call initialisation routines
  rcall INITSYS
;Enable interrupts
  bsf INTCON,GIE,ACCESS
  bsf INTCON,PEIE,ACCESS

;Start of the main program
;dir portb.7 out
  bcf TRISB,7,ACCESS
;InitTimer0(Osc, (TMR0_FOSC4 + PRE0_32) , POST0_1)
  movlw 1
  movwf TMRSOURCE,BANKED
  movlw 69
  movwf TMRPRES,BANKED
  clrf  TMRPOST,BANKED
  rcall INITTIMER0146

;SetTimer(0, 0xF900) ' Preload Count for 1ms '
  clrf  TMRNUMBER,BANKED
  clrf  TMRVALUE,BANKED
  movlw 249
  movwf TMRVALUE_H,BANKED
  rcall SETTIMER

;StartTimer 0
  clrf  TMRNUMBER,BANKED
  rcall STARTTIMER

;On Interrupt Timer0Overflow Call TMR0_ISR
  bsf INTCON,TMR0IE,ACCESS
;do
SysDoLoop_S1
;loop
  bra SysDoLoop_S1
SysDoLoop_E1
;End
  bra BASPROGRAMEND
BASPROGRAMEND
  sleep
  bra BASPROGRAMEND

;********************************************************************************

INITSYS
;[canskip] SPLLEN, IRCF2, IRCF1, IRCF0 = b'1110'
  bsf OSCTUNE,PLLEN,ACCESS
  bsf OSCCON,IRCF2,ACCESS
  bsf OSCCON,IRCF1,ACCESS
  bcf OSCCON,IRCF0,ACCESS
;BSR = 0
  clrf  BSR,ACCESS
;TBLPTRU = 0
  clrf  TBLPTRU,ACCESS
;SET ADFM OFF
  bcf ADCON2,ADFM,ACCESS
;SET ADCON0.ADON OFF
  bcf ADCON0,ADON,ACCESS
;ANSELA = 0
  banksel ANSELA
  clrf  ANSELA,BANKED
;ANSELB = 0
  clrf  ANSELB,BANKED
;ANSELC = 0
  clrf  ANSELC,BANKED
;#IFDEF bit(C2ON): C2ON = 0: #ENDIF
  bcf CM2CON,C2ON,ACCESS
;#IFDEF bit(CM2CON0_EN): CM2CON0_EN = 0: #ENDIF
;#IFDEF bit(C1ON): C1ON = 0: #ENDIF
  bcf CM1CON,C1ON,ACCESS
;#IFDEF bit(CM1CON0_EN): CM1CON0_EN = 0: #ENDIF
;PORTA = 0
  clrf  PORTA,ACCESS
;PORTB = 0
  clrf  PORTB,ACCESS
;PORTC = 0
  clrf  PORTC,ACCESS
;PORTE = 0
  clrf  PORTE,ACCESS
  banksel 0
  return

;********************************************************************************

;Overloaded signature: BYTE:BYTE:BYTE:
INITTIMER0146
  return

;********************************************************************************

Interrupt
;Save Context
  movff WREG,SysW
  movff STATUS,SysSTATUS
  movff BSR,SysBSR
;Store system variables
  movff SysTemp1,SaveSysTemp1
;On Interrupt handlers
  btfss INTCON,TMR0IE,ACCESS
  bra NotTMR0IF
  btfss INTCON,TMR0IF,ACCESS
  bra NotTMR0IF
  rcall TMR0_ISR
  bcf INTCON,TMR0IF,ACCESS
  bra INTERRUPTDONE
NotTMR0IF
;User Interrupt routine
INTERRUPTDONE
;Restore Context
;Restore system variables
  movff SaveSysTemp1,SysTemp1
  movff SysW,WREG
  movff SysSTATUS,STATUS
  movff SysBSR,BSR
  retfie  0

;********************************************************************************

SETTIMER
;If TMRNumber = 0 Then
  movf  TMRNUMBER,F,BANKED
  btfsc STATUS, Z,ACCESS
;TMR0L = TMRValue
  movff TMRVALUE,TMR0L
;End If
;If TMRNumber = 1 then
  decf  TMRNUMBER,W,BANKED
  btfss STATUS, Z,ACCESS
  bra ENDIF11
;TMR1H = TMRValue_H
  movff TMRVALUE_H,TMR1H
;TMR1L = TMRValue
  movff TMRVALUE,TMR1L
;End If
ENDIF11
;If TMRNumber = 2 Then
  movlw 2
  subwf TMRNUMBER,W,BANKED
  btfsc STATUS, Z,ACCESS
;TMR2 = TMRValue
  movff TMRVALUE,TMR2
;End If
;If TMRNumber = 3 then
  movlw 3
  subwf TMRNUMBER,W,BANKED
  btfss STATUS, Z,ACCESS
  bra ENDIF13
;TMR3H = TMRValue_H
  movff TMRVALUE_H,TMR3H
;TMR3L = TMRValue
  movff TMRVALUE,TMR3L
;End If
ENDIF13
;If TMRNumber = 4 Then
  movlw 4
  subwf TMRNUMBER,W,BANKED
  btfsc STATUS, Z,ACCESS
;TMR4 = TMRValue
  movff TMRVALUE,TMR4
;End If
;If TMRNumber = 5 then
  movlw 5
  subwf TMRNUMBER,W,BANKED
  btfss STATUS, Z,ACCESS
  bra ENDIF15
;TMR5H = TMRValue_H
  movff TMRVALUE_H,TMR5H
;TMR5L = TMRValue
  movff TMRVALUE,TMR5L
;End If
ENDIF15
;If TMRNumber = 6 Then
  movlw 6
  subwf TMRNUMBER,W,BANKED
  btfsc STATUS, Z,ACCESS
;TMR6 = TMRValue
  movff TMRVALUE,TMR6
;End If
  return

;********************************************************************************

STARTTIMER
;IF TMRNumber = 0 then Set TMR0ON on
  movf  TMRNUMBER,F,BANKED
  btfsc STATUS, Z,ACCESS
  bsf T0CON,TMR0ON,ACCESS
;IF TMRNumber = 1 then Set TMR1ON on
  decf  TMRNUMBER,W,BANKED
  btfsc STATUS, Z,ACCESS
  bsf T1CON,TMR1ON,ACCESS
;IF TMRNumber = 2 then Set TMR2ON on
  movlw 2
  subwf TMRNUMBER,W,BANKED
  btfsc STATUS, Z,ACCESS
  bsf T2CON,TMR2ON,ACCESS
;IF TMRNumber = 3 then Set TMR3ON on
  movlw 3
  subwf TMRNUMBER,W,BANKED
  btfsc STATUS, Z,ACCESS
  bsf T3CON,TMR3ON,ACCESS
;IF TMRNumber = 4 then Set TMR4ON on
  movlw 4
  subwf TMRNUMBER,W,BANKED
  btfss STATUS, Z,ACCESS
  bra ENDIF7
  banksel T4CON
  bsf T4CON,TMR4ON,BANKED
ENDIF7
;IF TMRNumber = 5 then Set TMR5ON on
  movlw 5
  banksel TMRNUMBER
  subwf TMRNUMBER,W,BANKED
  btfss STATUS, Z,ACCESS
  bra ENDIF8
  banksel T5CON
  bsf T5CON,TMR5ON,BANKED
ENDIF8
;IF TMRNumber = 6 then Set TMR6ON on
  movlw 6
  banksel TMRNUMBER
  subwf TMRNUMBER,W,BANKED
  btfss STATUS, Z,ACCESS
  bra ENDIF9
  banksel T6CON
  bsf T6CON,TMR6ON,BANKED
ENDIF9
  banksel 0
  return

;********************************************************************************

TMR0_ISR
;portb.7 = not portb.7
  clrf  SysTemp1,BANKED
  btfsc PORTB,7,ACCESS
  incf  SysTemp1,F,BANKED
  comf  SysTemp1,F,BANKED
  bcf LATB,7,ACCESS
  btfsc SysTemp1,0,BANKED
  bsf LATB,7,ACCESS
;
;SetTimer(0, 0xFA00) ' reset count for 1ms adj for isr time'
  clrf  TMRNUMBER,BANKED
  clrf  TMRVALUE,BANKED
  movlw 250
  movwf TMRVALUE_H,BANKED
  rcall SETTIMER

  return

;********************************************************************************


 END
the final hex file is much shorter after compiling though.
If I change the header to #chip 328p ie arduino uno then the assembler is very different.
 
Last edited:

tmfkam

Senior Member
re tmfkam comment. The GCB guys are having probs with some 18f pics and the microchip docs pll osc speed info is incorrect for bits set so it's trial error testing cos the dev guys are fussy all pics and avr work. It shows with incorrect baud rate using terminal. Microchip got complicated since me using notepad,mpasm and programmer flash hex.
I used picaxe happily until I got a ssd1306 graphic lcd. No support but forum helped me lots but picaxe is too slow for drawing lines ie lots of calculated pixels.
Forget pic asm, GCB generated asm is optimised and better than I could write. Get a uno for £3 (just plug in usb lead) and try GCB cos it's free
While there have been a number of release candidates for the most recent version of GCB, I have found all full releases to be rock solid.

I did recently discover a problem compiling a section of code that should have enabled me to store a 'Long' variable into EeProm, which sent me round in circles for a while. Once I discovered that passing a Long variable value into a SubRoutine caused that Long variable to become truncated to a Word, I soon came up with a fix. Not only that but shortly after, the developers sent me a test version of the compiler which corrected the original problem, and a further one discovered at the same time. This fix has now found it's way into the latest full release.

We do need to remember that GCB is software developed by people in their spare time. This limits the effort that can be put into it and that also limits the testing that can be done on the software, which goes some way to explaining the number of release candidates that have been placed for testing by users. In effect, those users share the time costs of the test cycle.

I'm still not that enamoured with Arduino. While many of the Arduino products have built in USB capabilities that allow programming without the need for any special programmers, once you separate the active device from the board in order to build it into a commercial product, additional hardware is required. Either on the board, in the shape of a USB interface, or a different programming interface to program the 'naked' chips. If those 'naked' chips don't have a pre-loaded bootloader, they then cannot be programmed in the same manner as those on the boards, which usually do. All this confuses my already confused mind and I struggle to see what I actually need (or don't need) to progress beyond a full board. That is my reason for sticking with the PIC, and in particular, my favourites the 16F1825/1829.
 

stan74

Senior Member
Picaxe is easy, I used their rs232 to 3.5 jack and made a board. Same with gcb and pic but uses pickit2 clone and resistor/diode/cap in circuit programming. No boot loader.
Arduino uno on gcb easier. I use the bootloader that it comes with and usb, bonus, uno can send to terminal through usb, pics need wiring to rs232 or usb serial converter...microchip express board for £9 from RS is like a uno..sort of.
I recently got a 32bit duo and glcd bridge thingy but never done any arduino sketch or used the ide yet. C++ is too simple yet complicated.
My favourite is 18f25k22. 28 pin and plenty ram,64
the "uno" 328p, 28 pin,less ram,less a-d pins but runs an instruction every clock cycle not every 4 like pic but max clock 16 meg not 64. a clone board is same price as the 328p alone.
With assembler on pic it's not just code it's all the bit settings for interrupts and timers and pwm ccpm modules. better if the compiler sorts that stuff for you. It's where mistakes happen.
 
Top