![]() |
Forum Index : Microcontroller and PC projects : Firewing or VB.net for PIC24HJ
![]() ![]() ![]() ![]() |
|||||
Author | Message | ||||
atmega8![]() Guru ![]() Joined: 19/11/2013 Location: GermanyPosts: 723 |
Thank you Vasi, that gives me a good overview. First thing i would like to achive is to let some LED''s flash on my ubw32. Without a bootloader, just a Firewing programm, burned with my Pickit3. This must be possible?! Or is it a limitation of firewing, when why? Dietmar |
||||
kiiid Guru ![]() Joined: 11/05/2013 Location: United KingdomPosts: 671 |
Hey, this is really cool. Thanks for providing the link, vasi http://rittle.org -------------- |
||||
JohnS Guru ![]() Joined: 18/11/2011 Location: United KingdomPosts: 3998 |
I already tried his site but could not find an answer. I never mentioned Microchip so don't understand why you did. Didn't read my questions properly? John |
||||
vasi![]() Guru ![]() Joined: 23/03/2007 Location: RomaniaPosts: 1697 |
I meant Microsoft, the creator of the true VB.Net . Sometimes, a dialect of BASIC language became a reference and a standard for that language because of his popularity. On the author's home page (the second paragraph) you can read the following: [quote="David Barker"]The language syntax is similar to that used by VB.NET, so it's really easy to use. Don't let the fact that it based on the VB.NET syntax fool you, the Firewing compiler does not generate interpreted code! It's a true compiler, based around the powerful GCC toolsuite.[/quote] Now, what follows (this is from the forums and is harder to find) is an answer to you regarding an older reply by you on another thread (you will understand what I mean). A user asked David why Firewing BASIC is not identical with Swordfish BASIC, a language he was used to it. David answered [quote="David Barker"]The Swordfish language was a mix of BASICs, PASCAL etc. It was made up. Firewing follows closely the VB.NET syntax so it's more standards based. For example, take a look at some of these examples: http://msdn.microsoft.com/en-us/library/752y8abs.aspx http://www.dotnetperls.com/structure http://www.tutorialspoint.com/vb.net/vb.net_functions.htm and look at the sample code - 3 different website resources with code that looks like Firewing! If you learn Firewing, you are picking up the non-class based parts of VB.NET. If you know VB.NET, moving to Firewing is very easy. Obviously there are differences, but "C" is a standard that you need to tweak between systems. I've had people in the past say they don't use Swordfish, PROTON, PicBASIC etc because it's not a standard language like "C" and you cannot transfer the skills used. Well, now you have Firewing which uses a standard approach to BASIC. Skills you lean with Firewing can be used in other domains. [/quote] I marked bold a phrase for you. Here is the reference. Hobbit name: Togo Toadfoot of Frogmorton Elvish name: Mablung Miriel Beyound Arduino Lang |
||||
vasi![]() Guru ![]() Joined: 23/03/2007 Location: RomaniaPosts: 1697 |
Dietmar, here is the Basic code for blinking a LED on RB14 pin but everything depends on the used linker script - how to specify that to IDE, I don't know yet so we better ask David. [quote]sub main() TRISB.14 = 0 ' make pin output while true PORTB.14 = 1 ' switch on LED delayms(500) ' wait 0.5 seconds PORTB.14 = 0 ' switch LED off delayms(500) ' wait 0.5 seconds end while end sub[/quote] I tried to be smart: Quote shows the colors but don't indent the code, and the other don't show the colors [code]sub main() TRISB.14 = 0 ' make pin output while true PORTB.14 = 1 ' switch on LED delayms(500) ' wait 0.5 seconds PORTB.14 = 0 ' switch LED off delayms(500) ' wait 0.5 seconds end while end sub[/code] Hobbit name: Togo Toadfoot of Frogmorton Elvish name: Mablung Miriel Beyound Arduino Lang |
||||
JohnS Guru ![]() Joined: 18/11/2011 Location: United KingdomPosts: 3998 |
Vasi - thanks. Similar to says it all. John |
||||
atmega8![]() Guru ![]() Joined: 19/11/2013 Location: GermanyPosts: 723 |
Hi vasi, in the meantime i was able to compile and prog the UBW32 with firewing;-).. I used your blinking code for a first test, it works!! But i have some other (Beginner) Problems. Read here, David responded immediately : Firewing There must be some clock Option....?? |
||||
vasi![]() Guru ![]() Joined: 23/03/2007 Location: RomaniaPosts: 1697 |
Try to include under device the following line clock = 80 But try also what David said (well, you should do that first). Regarding configuration bits, you do things like this (under the clock): Config WDT = ON ' and so on... You must find out what were the configuration bits of your UBW32 HID bootloader. Then compare their name with the ones from include file (32MX795F512L.BAS) to have the correct ones. Hobbit name: Togo Toadfoot of Frogmorton Elvish name: Mablung Miriel Beyound Arduino Lang |
||||
atmega8![]() Guru ![]() Joined: 19/11/2013 Location: GermanyPosts: 723 |
Vasi, that points me in the right direction. David has answered further of my questions. Take a look at The forum. Dietmar |
||||
vasi![]() Guru ![]() Joined: 23/03/2007 Location: RomaniaPosts: 1697 |
I found the configuration bits for your board (careful, is a "C" code). Tell me if you can't adapt for Firewing. [code] #pragma config FPLLODIV = DIV_1 // PLL Output Divider #pragma config UPLLEN = ON // USB PLL Enabled #pragma config UPLLIDIV = DIV_2 // USB PLL Input Divider #pragma config FPLLMUL = MUL_20 // PLL Multiplier #pragma config FPLLIDIV = DIV_2 // PLL Input Divider #pragma config FWDTEN = OFF // Watchdog Timer #pragma config FPBDIV = DIV_1 // Peripheral Clock divisor #pragma config WDTPS = PS1 // Watchdog Timer Postscale #pragma config FCKSM = CSECME // Clock Switching & Fail Safe Clock Monitor enabled #pragma config OSCIOFNC = OFF // CLKO Enable #pragma config POSCMOD = XT // Primary Oscillator #pragma config IESO = ON // Internal/External Switch-over #pragma config FSOSCEN = OFF // Secondary Oscillator Enable (KLO was off) #pragma config FNOSC = PRIPLL // Oscillator Selection #pragma config CP = OFF // Code Protect #pragma config BWP = OFF // Boot Flash Write Protect #pragma config PWP = OFF // Program Flash Write Protect #pragma config ICESEL = ICS_PGx2 // ICE/ICD Comm Channel Select #pragma config DEBUG = OFF // Background Debugger Enable [/code] Hobbit name: Togo Toadfoot of Frogmorton Elvish name: Mablung Miriel Beyound Arduino Lang |
||||
atmega8![]() Guru ![]() Joined: 19/11/2013 Location: GermanyPosts: 723 |
Super, did you find it in the ubw32 sources? Now i have to read and understand the PIC Datasheet...;-) Lot of stuff! |
||||
vasi![]() Guru ![]() Joined: 23/03/2007 Location: RomaniaPosts: 1697 |
Yes, from your bootloader sources. Now, if you don't use the bootloader any more, every application must include those configuration bits. Hobbit name: Togo Toadfoot of Frogmorton Elvish name: Mablung Miriel Beyound Arduino Lang |
||||
vasi![]() Guru ![]() Joined: 23/03/2007 Location: RomaniaPosts: 1697 |
Dietmar, I don't know how configuration bits are added to the "C" code by the BASIC parser, as that C code is deleted immediately, and also I'm not familiar with the device include file in BASIC language, but you can try this code? [code] Device = 32MX795F512L Clock = 80 sub main() DEVCFG0 = &H7FFFFFFF ' these are equivalents of your cfg.bits DEVCFG1 = &HFF600DDB DEVCFG2 = &HFFF879D9 DEVCFG3 = &HFFFFFFFF TRISB.14 = 0 ' make pin output while true PORTB.14 = 1 ' switch on LED delayms(500) ' wait 0.5 seconds PORTB.14 = 0 ' switch LED off delayms(500) ' wait 0.5 seconds end while end sub [/code] I saw DEVCFGx defined in the device include file, but I don't know what is the right way to work with it (it does not accept the "config" keyword). The code compiles fine but if the BASIC parser rewrite the configuration bits with some defaults, then you only can set them from your Pickit 3 software. Until some forums members will decide to help you. Anyway, from now on it depends on you, I won't be able to help you any further. Personally I will wait for the final version to evaluate it (and of course, for a proper user manual). Hobbit name: Togo Toadfoot of Frogmorton Elvish name: Mablung Miriel Beyound Arduino Lang |
||||
atmega8![]() Guru ![]() Joined: 19/11/2013 Location: GermanyPosts: 723 |
Vasi, did it like David posted. LEE blinks 10-12 times to slow with this config bits... |
||||
vasi![]() Guru ![]() Joined: 23/03/2007 Location: RomaniaPosts: 1697 |
What David gave you, use it only as an example (template) to write your configuration bits (like in the USB HID Bootloader of your board) Hobbit name: Togo Toadfoot of Frogmorton Elvish name: Mablung Miriel Beyound Arduino Lang |
||||
vasi![]() Guru ![]() Joined: 23/03/2007 Location: RomaniaPosts: 1697 |
Is about this code. The configuration bits are identical with the ones used by hid bootloader for your hardware configuration. Download the bootloader sources from UBW32 site and have a look. But first, try to compile this program. [code] Device = 32MX795F512L Clock = 80 public config FPLLODIV(FPLLODIV) = {DIV_1} public config UPLLEN(UPLLEN) = {ON} public config UPLLIDIV(UPLLIDIV) = {DIV_2} public config FPLLMUL(FPLLMUL) = {MUL_20} public config FPLLIDIV(FPLLIDIV) = {DIV_2} public config FWDTEN(FWDTEN) = {ON, OFF} public config FPBDIV(FPBDIV) = {DIV_1} public config WDTPS(WDTPS) = {PS1} public config FCKSM(FCKSM) = {CSECME} public config OSCIOFNC(OSCIOFNC) = {OFF} public config POSCMOD(POSCMOD) = {XT} public config IESO(IESO) = {ON} public config FSOSCEN(FSOSCEN) = {OFF} public config FNOSC(FNOSC) = {PRIPLL} ' set config for program... config FPLLODIV = DIV_1 // PLL Output Divider config UPLLEN = ON // USB PLL Enabled config UPLLIDIV = DIV_2 // USB PLL Input Divider config FPLLMUL = MUL_20 // PLL Multiplier config FPLLIDIV = DIV_2 // PLL Input Divider config FWDTEN = OFF // Watchdog Timer config FPBDIV = DIV_1 // Peripheral Clock divisor config WDTPS = PS1 // Watchdog Timer Postscale config FCKSM = CSECME // Clock Switching & Fail Safe Clock Monitor enabled config OSCIOFNC = OFF // CLKO Enable config POSCMOD = XT // Primary Oscillator config IESO = ON // Internal/External Switch-over config FSOSCEN = OFF // Secondary Oscillator Enable (KLO was off) config FNOSC = PRIPLL // Oscillator Selection Sub Main() TRISB.14 = 0 ' make pin output TRISE.0 =0 while true PORTB.14 = 1 ' switch on LED PORTE.0 = 1 delayms(500) ' wait 0.5 seconds PORTB.14 = 0 ' switch LED off PORTE.0 =0 delayms(500) ' wait 0.5 seconds end while End Sub [/code] Hobbit name: Togo Toadfoot of Frogmorton Elvish name: Mablung Miriel Beyound Arduino Lang |
||||
vasi![]() Guru ![]() Joined: 23/03/2007 Location: RomaniaPosts: 1697 |
Just to let you know that with the configuration above, Dietmar (@Atmega8) got the LED flashing at the desired frequency. The above can be used as a template in defining the configuration bits for your own boards. David uploaded a new beta version of FirewingIDE and Microchip32 toolchain. Anyway, many of the Firewing libraries will use Arduino pin-out abstraction defined on Firewing R1, Firewing R2, Chipkit UNO, Chipkit MAX32 board layouts. If you have a 28pin micro, or a micro similar to the one used in one of Chipkit boards, you can consider having the same layout for the pin-out and peripherals, even if your microchip is a different model. Is working out of the box for official boards, but if you have something different, you have to realize that you have to "hack the system" - that will happen in the limits set by David. I mean, if the Basic parser will allow it, then is legal. But consider buying a board when you can afford it. Hobbit name: Togo Toadfoot of Frogmorton Elvish name: Mablung Miriel Beyound Arduino Lang |
||||
atmega8![]() Guru ![]() Joined: 19/11/2013 Location: GermanyPosts: 723 |
@ Vasi, you showed me the interesting firewing, which i never heared before. For you now this extremly interesting and very stable Compilerfor nearly all atmega Controllers. Very developed and mature and of course for FREEEEEEE! Supports many stuff with its libraries (I2C/LCD/PWM/SPI/....) and support for graphical touch displays. You'll be amazed ;-) Hope the english documentation is as good as the german. LUNA AVR |
||||
atmega8![]() Guru ![]() Joined: 19/11/2013 Location: GermanyPosts: 723 |
Works with the UBW32 from Brian Schmalz UBW32 Code, blink.bas ' Declarations... Device = 32MX795F512L clock = 80 'Setting the Config bits of the 32MX795F512L public config FPLLODIV(FPLLODIV) = {DIV_1} public config UPLLEN(UPLLEN) = {ON} public config UPLLIDIV(UPLLIDIV) = {DIV_2} public config FPLLMUL(FPLLMUL) = {MUL_20} public config FPLLIDIV(FPLLIDIV) = {DIV_2} public config FWDTEN(FWDTEN) = {ON, OFF} public config FPBDIV(FPBDIV) = {DIV_1} public config WDTPS(WDTPS) = {PS1} public config FCKSM(FCKSM) = {CSECME} public config OSCIOFNC(OSCIOFNC) = {OFF} public config POSCMOD(POSCMOD) = {XT} public config IESO(IESO) = {ON} public config FSOSCEN(FSOSCEN) = {OFF} public config FNOSC(FNOSC) = {PRIPLL} ' set config bits for UBW32 Hardware ' on board 8 MHz Quarz config FPLLODIV = DIV_1 // PLL Output Divider config UPLLEN = ON // USB PLL Enabled config UPLLIDIV = DIV_2 // USB PLL Input Divider config FPLLMUL = MUL_20 // PLL Multiplier config FPLLIDIV = DIV_2 // PLL Input Divider config FWDTEN = OFF // Watchdog Timer config FPBDIV = DIV_1 // Peripheral Clock divisor config WDTPS = PS1 // Watchdog Timer Postscale config FCKSM = CSECME // Clock Switching & Fail Safe Clock Monitor enabled config OSCIOFNC = OFF // CLKO Enable config POSCMOD = XT // Primary Oscillator config IESO = ON // Internal/External Switch-over config FSOSCEN = OFF // Secondary Oscillator Enable (KLO was off) config FNOSC = PRIPLL // Oscillator Selection ' the simple .net code Sub Main() 'TRISB.14 = 0 ' make pin output TRISE.0 =0 TRISE = 0 ' make whole port output while true 'PORTE.0 = 1 PORTE = 255 'Port E High delayms(500) ' wait 0.5 seconds 'PORTE.0 =0 PORTE = 0 delayms(500) ' wait 0.5 seconds end while End Sub |
||||
atmega8![]() Guru ![]() Joined: 19/11/2013 Location: GermanyPosts: 723 |
LUNA AVR Language: The best of Pascal, Basic and C,, Easy, clear, straight Forward but not for PIC's ;-() |
||||
![]() ![]() ![]() ![]() |
![]() |
![]() |
The Back Shed's forum code is written, and hosted, in Australia. | © JAQ Software 2025 |