![]() |
Forum Index : Microcontroller and PC projects : Pic32Prog mmbasic+program into a file
Page 1 of 2 ![]() ![]() |
|||||
Author | Message | ||||
Quazee137![]() Guru ![]() Joined: 07/08/2016 Location: United StatesPosts: 593 |
I use Pic32Prog to load MMBasic on to the 28 pinners. Now I need to save MMBasic and the program with library and options so I can program 60 chips. In using "pic32prog -r project.hex address length" what values do address and length need to be. That is if this will work ![]() Thanks Quazee137 Wired this up last night on a piece of perf . surprised it went so easily ![]() ![]() ![]() ![]() |
||||
Grogster![]() Admin Group ![]() Joined: 31/12/2012 Location: New ZealandPosts: 9610 |
Don't THINK you can read chips with pic32prog. I think you can only PROGRAM chips with that utility. Peter or Rob will correct me here if I am wrong. If you want to read the entire MM chip into a HEX to program into other chips, you will probably have to use the Microchip IPE and a PicKit3 unit. Once you HAVE the HEX file, you can then use pic32prog to program all the virgin chips with your customised HEX. ![]() Smoke makes things work. When the smoke gets out, it stops! |
||||
robert.rozee Guru ![]() Joined: 31/12/2012 Location: New ZealandPosts: 2442 |
certainly, when i wrote the 'ascii ICSP' extensions for pic32prog, every code stub was completed, including those for reading the flash. so in theory pic32prog should be capable of reading an mx170, but it has never been tested as far as i am aware - i never knew what addresses to use! geoff and/or peter may have some ideas. cheers, rob :-) |
||||
Geoffg![]() Guru ![]() Joined: 06/06/2011 Location: AustraliaPosts: 3292 |
For the MX170 there are three areas: Program flash from 0x9D00000 to 0x9D00FFFF Boot flash from 0x9FC00000 to 0x9FC00BEF Config registers from 0x9FC00BF0 to 0x9FC00BFF These are combined into one HEX file by the PIC32 linker/loader but I am not sure how this is done and what format is used but pic32prog happily accepts it. When you use the PICkit3 to read a chip it automatically reads all three and spits out a HEX file acceptable to pic32prog. Geoff Geoff Graham - http://geoffg.net |
||||
JohnS Guru ![]() Joined: 18/11/2011 Location: United KingdomPosts: 4044 |
You may have to do 3 reads - one for each of those ranges. You can then just join the files (in any order) (use cat if on Linux, or copy in a command window) and you should have an OK file to use. hmm... well, somewhat in theory. Try the above. Then program a blank chip and see if it works. If it fails, by all means post your original used to program the chip and the 3 files and I'll take a look. (I'm wondering if there's a virtual/physical mapping needed.) John |
||||
Grogster![]() Admin Group ![]() Joined: 31/12/2012 Location: New ZealandPosts: 9610 |
This is interesting information. I did not think you could read with pic32prog. @ Rob - perhaps time to update your GUI frontend so it can read too... ![]() I might have to try this at the DOS command line to see what happens - if I can find a spare second or two, which is never easy.... Smoke makes things work. When the smoke gets out, it stops! |
||||
Quazee137![]() Guru ![]() Joined: 07/08/2016 Location: United StatesPosts: 593 |
In playing with this I found that the file type switch does not work ![]() and it has to be a .bin file pic32prog -d ascii:/dev/ttyACM0 -r file#1.bin 0x9D000000 0xFFFF pic32prog -d ascii:/dev/ttyACM0 -r file#2.bin 0x9FC00000 0x0BEF pic32prog -d ascii:/dev/ttyACM0 -r file#3.bin 0x9FC00BF0 0x000F I am reading the chip with these. The files are raw binary. I am looking at the mmbasic.hex to see what I can. looks like format is something like :address data cksum \n it may be :offset data cksum \n not sure as yet. Using hexdump -C file#1.bin > file#1.hex I can see the text in the file and I do see my program. A search for "String too long." Puts me at first line of text in my code. I need a few hex files done with the pickkit so I can break down the structure and see if I can build the three files into one hex file that will tell Pic32Prog what it needs. Fun stuff it is ![]() Quazee137 If this works it would be a great addon to MMEdit no need of a looooad of software or pickit3 to copy chips. |
||||
robert.rozee Guru ![]() Joined: 31/12/2012 Location: New ZealandPosts: 2442 |
hi, the intel hex format is relatively simple, i have decoded it in the past for programming atmel chips. as i recall there is a segment specifier you set up at the start of a block, and then each subsequent line starts with an offset that is combined with the segment to get an address. i thing the offset may be limited to 16-bits. very intel-esque. you really need to write a program that combines together SEVEN pieces of information: each of the three .bin files plus the segment associated with each, and the processor signature read out by pic32prog. if you look at the contents of the mmbasic firmware from geoff, you'll see that there are quite a number of block in the file, each with a different segment. this represents different bits of code stored in different places in flash, with blank gaps between some of them. but when all cut-and-pasted together into flash in the right order, they will fit together like the pieces of a jigsaw puzzle. cheers, rob :-) |
||||
PeterB Guru ![]() Joined: 05/02/2015 Location: AustraliaPosts: 655 |
G'Day All I admire and envy what you blokes are doing. I also like to dream that if I was 40 years younger I could be in there with you, perhaps ![]() Peter |
||||
Quazee137![]() Guru ![]() Joined: 07/08/2016 Location: United StatesPosts: 593 |
I'll be mid 60's next month so Im with you at going back 40 years. ![]() Soldering the board was done with a BIG piece of glass between me and it. ![]() Has any one got DOS MMBasic to run under linux? MY thought is that would be a good way to code for the needed hex file. ![]() Looking at the MMBasic hex file armed with WikipediA I now get a better understanding of the hex file structure (much has been added since my Z80 days). There are what looks like memory based registers pointers or extended addressing going on. Not simple as one would like. ![]() Again asking for a few hex files done with the pickkit3. Hoping these will be a road map into building the hex file. Quazee137 |
||||
Volhout Guru ![]() Joined: 05/03/2018 Location: NetherlandsPosts: 5091 |
Havent been able to run under linux. Dosbox does indicate it needs Windows. Wine doesn t like it either. I would have spend more time on it if the dos version had some elementary form of graphix. Volhout PicomiteVGA PETSCII ROBOTS |
||||
Quazee137![]() Guru ![]() Joined: 07/08/2016 Location: United StatesPosts: 593 |
Volhout Thanks for trying too. I tried a few ways still no luck. Funny thing I created a folder and put MMBasic.exe in it. then opened folder in a terminal then type wine MMBasic.exe I get this ![]() I can ^C and it responds moving the > down a line. But no other keys work. So near but so far away. ![]() seems right. With SYSTEM command-line$ MMBasic could be like a bash/bat doing the bit handling and passing the file out to Pic32Prog I had a pickit3 but never got it to work so I gave it to a student who has moved. Can any one make a hex file with mmbasic and a test program for me to take apart. I am dissecting the mmbasic hex but that wont show me how the program and options are done. I did flash the 60 chips and loaded the program just waiting for boards and din rail cases. Then the fun of hot air reflow. Been testing it out not to bad with solder paste. Thanks for the help and insight Quazee137 rob I cant search the forum our talks on GFXterm. But I think there was a font thing that you fixed so I could see the text. Now wondering if that is why I do not get text in the above image. |
||||
PeterB Guru ![]() Joined: 05/02/2015 Location: AustraliaPosts: 655 |
G'Day Quazee137 It looks like your mates have abandoned you. These young blokes can't be trusted ![]() Back when I was trying to solve the VAR RESTORE problem I finished up with 1 probable genuine PICKIT3, 1 clone and 1 dubious thing. I have never had a problem with the fist 2 other than GIGO. I have not used the third. I also made 2 of those PICPROG32 things, 1 with a SMPS and 1 with a linear supply. I like to run things on 12V and both work. Which does nothing to explain why you had a problem other than "where ignorance is bliss 'tis folly to be wise" Any way, given that I am an elderly idiot and must be treated with care, how can I help by generating your HEX code. In other words, how would you like it? Peter |
||||
PeterB Guru ![]() Joined: 05/02/2015 Location: AustraliaPosts: 655 |
And another thing. (talking about soldering) Some years ago my wife insisted on paying for a 3060 CNC machine for me. I have no idea why, guilt probably played a part but I love it. The thing is I can whip up the design of a simple board, engrave it and load it in 1 day. And the soldering is easy for old eyes and the finished product looks good and is road worthy. The only down side is it takes up a bit of space but Australia is a big country. Peter |
||||
robert.rozee Guru ![]() Joined: 31/12/2012 Location: New ZealandPosts: 2442 |
not quite abandoned, just mulling over the problem. i have an idea: someone burn a copy of mmbasic to an MX170, then use a pickit3 to read it back out and create a new .hex file using mplab. this new .hex file should, in theory, be pretty flat, contain no 'holes'. i'm assuming here that mplab doesn't do anything silly like skipping over blocks that contain all 1's. next, do the same using an ascii ICSP programmer (either arduino nano or 1455 based) and pic32prog. this will give a corresponding set of binary images. the .hex file can be used as a guide/template to figure out exactly what has to be done with the .bin files to create an identical .hex file. cheers, rob :-) |
||||
PeterB Guru ![]() Joined: 05/02/2015 Location: AustraliaPosts: 655 |
I figured you would be there but I couldn't resist the opportunity. ![]() As I said, 40 years ago I may have been able to keep up with you. Peter |
||||
Quazee137![]() Guru ![]() Joined: 07/08/2016 Location: United StatesPosts: 593 |
Here a program you can use ADC1115-test.bas.zip Rob's idea of just an mmbasic.hex is great can compare with Geoffg's file. Also something with some options set as theses should be in the final hex file. Rob I used the bridge to connect to a zif'd 170 board to read the three files. It's also the way I put MMBasic on the 60 chips. Then used the zif one I posted to upload the basic program. It was when I made the usb to zif that got me thinking of using Pic32Prog to read the preset up chip and do MMBasic + program + options for the rest. In previewing is looked like the testing zip file part was not working. So here it is again. Option explicit Dim float adc01,adc23,adc0,adc1,adc2,adc3,getvolts,tmp,ofs=-2.67 Dim startime$ RTC gettime RTC SETREG &h07,&h92 startime$=Time$ Dim fs=2,p=0 I2C open 100,5000 Box 0, 0, MM.HRes-1, MM.VRes-1, 8, , RGB(yellow) PWM 2,1000,50 ' 'SetTick 3600000,settime,1 'update time from RTC hourly SetTick 750,ADC,4 'periodical reading clr Do locate 5,1 Print startime$;" ";Time$;" " Print "Volts A01 is "; adc01 Print "Volts A23 is "; adc23 Print "----------------------" Print "Volts A0 is "; adc0 Print ((adc0-.4)/0.2925);"pH " Print "Volts A1 is "; adc1 Print (adc1-2.7315)*100 Print "Volts A2 is "; adc2 Print "Temp ";Str$((adc2-2.7315)*100,0,3);"C " Print "Temp ";Str$((adc2-2.7315)*100*(9/5)+32,0,3);"F " 'Print Str$((adc2-2.7315)*100*(9/5)+32+ofs,0,4);" F " Print "Volts A3 is "; adc3 Print "--------------------" tmp=TEMPR(16) Print "The temp ";Str$(tmp,0,3);" C ",Str$(tmp*1.8+32,0,3);" F " Text MM.HRes/2,30,Date$+" "+Time$,cm,1,fs,RGB(red),RGB(yellow) Text 10,40,"A01 is "+Str$(adc01,2,5),,1,fs,RGB(blue),RGB(yellow) Text 10,65,"A23 is "+Str$(adc23,2,5),,1,fs,RGB(blue),RGB(yellow) Text 10,90,"A0 is "+Str$(adc0,2,5),,1,fs,RGB(blue),RGB(yellow) Text 10,115,"A1 is "+Str$(adc1,2,5),,1,fs,RGB(blue),RGB(yellow) Text 10,140,"A2 is "+Str$(adc2,2,5),,1,fs,RGB(blue),RGB(yellow) Text 10,165,"A3 is "+Str$(adc3,2,5),,1,fs,RGB(blue),RGB(yellow) Text 10,190,"Tmp is "+Str$(tmp*1.8+32),,1,fs,RGB(blue),RGB(yellow) Loop Sub ADC ' ADC reading Local cfreg,cnv,cfhi,cflo cfreg = &h01: cnv =&h00 ' rate 128 sps no comp operations cfhi = &h83 : cflo= &h81 'reading Dif Ain0 , Ain1,FS= +/- 4.096 , 128 sps I2C write &H48,0,3,cfreg,cfhi,cflo 'adr 48 point to config reg I2C write &h48,0,1,cnv ' adr 48 point to conversion reg getadc adc01 = getvolts ' cfhi = &hB3 : cflo= &h81 ' reading Dif Ain2 , Ain3,FS= +/- 4.096 , 128 sps I2C write &H48,0,3,cfreg,cfhi,cflo 'adr 48 point to config reg I2C write &h48,0,1,cnv ' adr 48 point to conversion reg getadc adc23 = getvolts ' cfhi = &hC3 : cflo= &h81 ' reading single Ain0,FS= +/- 4.096 , 128 sps I2C write &H48,0,3,cfreg,cfhi,cflo 'adr 48 point to config reg I2C write &h48,0,1,cnv ' adr 48 point to conversion reg getadc adc0 = getvolts ' cfhi = &hD3 : cflo= &h81 ' reading single Ain1,FS= +/- 4.096 , 128 sps I2C write &H48,0,3,cfreg,cfhi,cflo 'adr 48 point to config reg I2C write &h48,0,1,cnv ' adr 48 point to conversion reg getadc adc1 = getvolts ' cfhi = &hE3 : cflo= &h81 ' reading single Ain2,FS= +/- 4.096 , 128 sps I2C write &H48,0,3,cfreg,cfhi,cflo 'adr 48 point to config reg I2C write &h48,0,1,cnv ' adr 48 point to conversion reg getadc adc2 = getvolts ' cfhi = &hf3 : cflo= &h81 ' reading single Ain1,FS= +/- 4.096 , 128 sps I2C write &H48,0,3,cfreg,cfhi,cflo 'adr 48 point to config reg I2C write &h48,0,1,cnv ' adr 48 point to conversion reg getadc adc3 = getvolts End Sub Sub getadc Local adcv Local integer adcrd(2) 'to receive 2 bytes Pause 100 I2C read &h48,0,2,adcrd() adcv= (adcrd(0)<<8) Or adcrd(1) If adcv > &H7fff Then adcv = adcv - &HFFFF getvolts = adcv *(4.096/32768) End Sub Sub settime RTC gettime Pause 50 End Sub Sub clr Print Chr$(27)+"[f" : Print Chr$(27)+"[2J" End Sub Sub locate x,y Print Chr$(27)+"["+Str$(X)+";"+Str$(Y)+"f"; End Sub again in the preview it looks odd but it's here. |
||||
Quazee137![]() Guru ![]() Joined: 07/08/2016 Location: United StatesPosts: 593 |
was going to edit out the preview parts as the look right in the post but no EDIT button. |
||||
PeterB Guru ![]() Joined: 05/02/2015 Location: AustraliaPosts: 655 |
Good morning Quazee137 & Rob. Are you bloke waiting for me to do something? Or, am I waiting for you to do something? Peter |
||||
robert.rozee Guru ![]() Joined: 31/12/2012 Location: New ZealandPosts: 2442 |
i'm waiting for someone to read out the firmware from a freshly programmed MX170 using a pickit3/mplab so that i can compare it to the original .hex file distributed by geoff. unfortunately the only pickit3 i have is set up for standalone programming 1455's, and i don't want to repurpose it. cheers, rob :-) |
||||
Page 1 of 2 ![]() ![]() |
![]() |
![]() |
The Back Shed's forum code is written, and hosted, in Australia. | © JAQ Software 2025 |