I have got the bas800 to do some assembler programming for fast signal manipulation which the PICAXE can't do.
I needed to adapt the p12f627.inc, looking at the memory organisation section in the datasheet, for the pic12f683, so I created the p12f683.inc file.
After working out all the registers I need to initialise, it only took me 3 downloads to perfect a 5-LED button-controlled runner using the PIC12F683. For one of them, I realized that the WDT resets the PIC if the 'clrwdt' instruction is not executed in a short time, which I think is actually otherwise useful when the program goes into a poll without setting it up correctly, when it might get stuck at the poll. I saw 'clrwdt' instructions in 'Wait.inc'. I've decided it is not required for this program so I turned it off in the config word. I was using the internal HFINTOSC at 4MHz. I always had the PIC datasheet up on the screen.
Now I want to use a 20MHz external oscillator module to eventually feed 3 PICs in a row. Problem: I apparantly found that in the PIC programmer software, the EC clock source option stays greyed out no matter what PIC I select from the menu, even on a PIC which supports EC (including the 12F683).
I apparantly found that the programming editor does have the option to download to PIC after I click the 'assemble' button, so I used it and it works great for the above. Problem: I have _EC_OSC in the configuration of another program (testing my bitbang serial code) I want to run, with an external oscillator module.
The program compiles OK, then when I click 'yes' for the 'assembly complete' message, and at the same time as the programming progress bar pops up, I get an error message saying 'Illegal switch' and titled 'Programming failed...' The progress bar seems to be downloading the program to the PIC the way I've seen before, but after it has finished verifying, the 'success' or 'failure' message like i've seen before does not appear. Here, I don't want to take the PIC out of the programmer in case it has the wrong oscillator setting. I have PE's PIC type set to PIC12F683.
The programmer software version is 4.3.12 and the Programmer (brought from Rapid) firmware version is v3.1. I've got PE 5.2.7.
I'll try programming the PIC with my LED flasher program, only with the _EC_OSC in the configuration bit instead of the other, making it 4 LEDs.
Update: the LED flasher modified for EC OSC programmed normally, with the 'sucsess' message at the end. So I'll probably need to check the suspect program, including the size.
U2: The program is only 400 commands, still under 2048 allowed according to the datasheet. So I'm not sure what 'illegal switch' means, when it pops up after the 'assembly complete' message. I'll try setting the oscillator to INT_OSC_IO and see.
U3: I have changed to _INT_OSC_IO in the suspect program and this time, a warning message titled 'wrong path...' pops up saying 'ErrorInvalid procedure call or argument', again after I click yes to the 'assembly complete' message. The file name is 683-ser-relay-t1.asm. I'll try changing it in case it shouldn't start with a number.
U4: Still the same error message popping up.
U5: The invalid call error popped up on the programs that did work before, so I restarted the programmer, then the LED flasher downloaded correctly. After this, I tried the suspect program with the _INT_OSC_IO, and the 'illegal switch' message popped up again, so now I know it must be something else! (I am using the same .inc file as in the LED flasher program which works).
U6: What?! I have (keeping the original file) stripped the suspect program right down to it's template stuff, and that 'illegal switch' message still appears!
That is so wierd, taking into account the start is now exactly the same as the start of the flasher program.
U7: Now I found it - it is the filename! I changed the dashes to spaces (also altering the filename a bit) and it programs properly. Then I put the dashes back on and then the 'illegal switch' message appears.
Therefore, all I have to do now is rid the filenames of dashes and I won't see this message again. Finally I can see if I can download the next full program.
Edit: It seems that the Illegal switch error pops up because the dashes mean the start of DOS command switches. The MPASM programs seem to parse switches like DOS did.
U8: the bitbang serial in/out relay test program works.
I needed to adapt the p12f627.inc, looking at the memory organisation section in the datasheet, for the pic12f683, so I created the p12f683.inc file.
After working out all the registers I need to initialise, it only took me 3 downloads to perfect a 5-LED button-controlled runner using the PIC12F683. For one of them, I realized that the WDT resets the PIC if the 'clrwdt' instruction is not executed in a short time, which I think is actually otherwise useful when the program goes into a poll without setting it up correctly, when it might get stuck at the poll. I saw 'clrwdt' instructions in 'Wait.inc'. I've decided it is not required for this program so I turned it off in the config word. I was using the internal HFINTOSC at 4MHz. I always had the PIC datasheet up on the screen.
Now I want to use a 20MHz external oscillator module to eventually feed 3 PICs in a row. Problem: I apparantly found that in the PIC programmer software, the EC clock source option stays greyed out no matter what PIC I select from the menu, even on a PIC which supports EC (including the 12F683).
I apparantly found that the programming editor does have the option to download to PIC after I click the 'assemble' button, so I used it and it works great for the above. Problem: I have _EC_OSC in the configuration of another program (testing my bitbang serial code) I want to run, with an external oscillator module.
The program compiles OK, then when I click 'yes' for the 'assembly complete' message, and at the same time as the programming progress bar pops up, I get an error message saying 'Illegal switch' and titled 'Programming failed...' The progress bar seems to be downloading the program to the PIC the way I've seen before, but after it has finished verifying, the 'success' or 'failure' message like i've seen before does not appear. Here, I don't want to take the PIC out of the programmer in case it has the wrong oscillator setting. I have PE's PIC type set to PIC12F683.
The programmer software version is 4.3.12 and the Programmer (brought from Rapid) firmware version is v3.1. I've got PE 5.2.7.
I'll try programming the PIC with my LED flasher program, only with the _EC_OSC in the configuration bit instead of the other, making it 4 LEDs.
Code:
__CONFIG _CP_OFF & _WDT_OFF & _EC_OSC & _PWRTE_ON & _BODEN_OFF & _MCLRE_OFF
In the include file:
_FCMEN_ON EQU B'11111111111111'
_FCMEN_OFF EQU B'11011111111111'
_IESO_ON EQU B'11111111111111'
_IESO_OFF EQU B'11101111111111'
_CPD_ON EQU B'11111101111111'
_CPD_OFF EQU B'11111111111111'
_CP_ON EQU B'11111110111111'
_CP_OFF EQU B'11111111111111'
_BODEN_ON EQU B'11111111111111'
_BODEN_ON_SLEEPOFF EQU B'11111011111111'
_BODEN_CONTROLLABLE EQU B'11110111111111'
_BODEN_OFF EQU B'11110011111111'
_MCLRE_ON EQU B'11111111111111'
_MCLRE_OFF EQU B'11111111011111'
_PWRTE_OFF EQU B'11111111111111'
_PWRTE_ON EQU B'11111111101111'
_WDT_ON EQU B'11111111111111'
_WDT_OFF EQU B'11111111110111'
_LP_OSC EQU B'11111111111000'
_XT_OSC EQU B'11111111111001'
_HS_OSC EQU B'11111111111010'
_EC_OSC EQU B'11111111111011'
_INT_OSC_IO EQU B'11111111111100'
_INT_OSC_CLKOUT EQU B'11111111111101'
_RC_OSC_IO EQU B'11111111111110'
_RC_OSC_CLKOUT EQU B'11111111111111'
Update: the LED flasher modified for EC OSC programmed normally, with the 'sucsess' message at the end. So I'll probably need to check the suspect program, including the size.
U2: The program is only 400 commands, still under 2048 allowed according to the datasheet. So I'm not sure what 'illegal switch' means, when it pops up after the 'assembly complete' message. I'll try setting the oscillator to INT_OSC_IO and see.
U3: I have changed to _INT_OSC_IO in the suspect program and this time, a warning message titled 'wrong path...' pops up saying 'ErrorInvalid procedure call or argument', again after I click yes to the 'assembly complete' message. The file name is 683-ser-relay-t1.asm. I'll try changing it in case it shouldn't start with a number.
U4: Still the same error message popping up.
U5: The invalid call error popped up on the programs that did work before, so I restarted the programmer, then the LED flasher downloaded correctly. After this, I tried the suspect program with the _INT_OSC_IO, and the 'illegal switch' message popped up again, so now I know it must be something else! (I am using the same .inc file as in the LED flasher program which works).
U6: What?! I have (keeping the original file) stripped the suspect program right down to it's template stuff, and that 'illegal switch' message still appears!
That is so wierd, taking into account the start is now exactly the same as the start of the flasher program.
U7: Now I found it - it is the filename! I changed the dashes to spaces (also altering the filename a bit) and it programs properly. Then I put the dashes back on and then the 'illegal switch' message appears.
Therefore, all I have to do now is rid the filenames of dashes and I won't see this message again. Finally I can see if I can download the next full program.
Edit: It seems that the Illegal switch error pops up because the dashes mean the start of DOS command switches. The MPASM programs seem to parse switches like DOS did.
U8: the bitbang serial in/out relay test program works.
Last edited: