• 0

Question

So I've been using GPUtils for a few weeks now, used to use MPASM back in the day on windows but I have to say I really like GPUtils.

So I've been playing around with this PIC 18F4520 IC I have and have been writing a pretty large program (in terms of pages). I've been frustrated for a whole day now on why a function won't work and has undesirable behaviour - returns 0 or crashes or resets the PIC... Then I realised something - the code was too long for one page and I've been coding in the next page without knowing it.

So (this is all reloctable code - NOT absolute) I read up on using BANKSEL and PAGESEL in GPUtils... Unfortunately, it appears to do buggar all, I'm not sure if I'm using it wrong or if features is bugged and just isn't working. This is the code I'm using (from the lst to see the addresses):

000288   0b0f	 andlw   0xf			  ANDLW b'00001111'
										   PAGESEL 400h
										   PAGESEL FUNC
00028a   ec00	 call    0x400, 0		 CALL FUNC
00028c   f002
										   PAGESEL $
00028e   0100	 movlb   0			    BANKSEL d2
.....
										   org 0x400

000400   010f	 movlb   0xf			  FUNC BANKSEL PCL
										   PAGESEL $
000402   6e02	 movwf   0x2, 0		   movwf d1
000404   0e04	 movlw   0x4			  movlw b'00000100'

And as can be seen - PAGESEL is doing nothing if I provide it with the function name or an address, I have to alter the PCLATH register manually as if I'm using absolute assembly which is a bit dumb and will always vary depending on what's added or what it's linked with or if anything is changed so I'm unsure if I'm doing something wrong or if I need to report a bug.

(Compiling using: gpasm -c 18f4520LCD.asm, linking using: gplink -m -c -s /usr/share/gputils/lkr/18f4520.lkr -o 18f4520LCD 18f4520LCD.o)

Anyone else got GPUtils, a programmer and can see if this is happening when they try this?

Thanks!

Link to comment
https://www.neowin.net/forum/topic/1133852-gputils-pic-bug/
Share on other sites

Recommended Posts

  • 0

Oh I don't believe it! I'm sure I read this RTC was 3.3v only so was using a 3.3v regulator and my 18LF4520... Now I read it needs 4.5-5.5v to function!

DAMNIT!

I'll program the normal 18f4520 sometime and try it.

EDIT: It's getting results now, not sure if they're correct but the seconds are changing... Feel like a right bloody tool for not working this out earlier :|

Edited by n_K
  • 0

Right, I'm reusing this thread! Got a pretty strange problem with the same microchip (18f4520) that I really can't quite get my head around...

Switched to using xc8 (free) and mplabx, and was experimenting with RS232 communication on the PIC, now for some reason for the example BAUDCON values provided in the datasheet, I've always had to use 1 less than the given value, so 11 instead of 12 for 19.2Kbps as if I use 12 it doesn't work, and this is connected up to a modified PC PSU with an LM7805 regulator on the 12V rail...

Now this has been working kinda well until I decided to switch over to the 5V rail as the regulator hasn't got a heatsink and I want to do some longer testing, switched it over and guess what? RS232 communication now fails, I get really weird values on the PC... So I recompiled my source but this time using the PROPER BAUDCON value specified in the datasheet, 12... Now RS232 communication works fine once again, but if I switch back to using the LM7805 it fails unless I switch BAUDCON BACK to 11.

I'm pretty perplexed by why the hell this is just playing up and being a nuisance, nothing is listed in the erratas about it. Measured the output voltage from the LM7805 and it's 4.99V, output from the 5V rail is 5.10V, and the PIC is using the internal oscillator set to run at 4MHz... So I can't really see or understand why a 0.11V difference means I need to use a different BAUDCON.

Has anyone got the foggiest idea why this is? What I do to fix this?

  • 0

You should always consider the value from the datasheet canonical. It is very rare that the manufacturer got the value wrong, especially for a large company like Microchip that tends to produce high quality documentation. I would suspect Microchip's compiler before the documentation, although the XC8 is GCC-based and immensely better than the previous two PIC16/PIC18 compilers they produced. The second setup with the 5V power supply sounds correct, and indeed appears to be based on your results. The first setup is suspect.

 

Assuming everything else stayed the same, it sounds like it might have something to do with your voltage regulator. According to their respective datasheets your regulator can produce up to 1.5A and your microcontroller can consume up to 300mA, so that shouldn't be a problem. What other devices do you have connected to your power rail? Are you trying to draw more than current than you regulator can provide?

  • 0

All that's connected up is the PIC, an elechouse RFID reader/writer (pulls up to 50mA) and a generic 16x2 LCD with backlight. When connected directly to the 5V rail it's pulling ~83mA in total which is more than enough for the setup. The 5V regulator is pulling 78mA from the 12V rail.

I'm using the standard reference implementation with the regulator with a 47uF 16V capacitor on the output of the regulator so to stabilise it. Still can't think why it'd be messed up.

  • 0

In that case I'm really not sure what the problem is. It sounds like you have your hardware setup correctly, but don't rule anything out too quickly. I have spend hours debugging my software just to discover that I had a bug in my hardware that "couldn't possibly happen", so I ruled it out hours before. (I have also had the same problem vice-versa. It's just part of microcontroller development, I think.) It doesn't sound like a power issue. The 11mV difference on your rail shouldn't be a problem; current draw is really what you should be looking at anyway.

  • 0

Haha I cannot actually believe this, fixed it. Replaced the 7805 with a LM2940CT-5 and behold it's working fine with the correct baud rate.

I started thinking there was something fishy with the regulator, put the LCD backlight and RFID reader power on transistors and it worked fine from the 5V rail but the 7805 regulator just made the screen backlight continually flash on and off in short bursts and wasn't powering the RFID reader or PIC.

Not sure what's up with the regulator, it's an official texas instruments one, well, the packaging states it is anyway. Picture is rubbish but here's a pic of the regulators, the TI 7805, 2*NI LM2940's and a Motorola 7905;

Ggj8gsS.jpg

Definately an interesting problem I've never seen or had before.

  • 0

Haha I cannot actually believe this, fixed it. Replaced the 7805 with a LM2940CT-5 and behold it's working fine with the correct baud rate.

I started thinking there was something fishy with the regulator, put the LCD backlight and RFID reader power on transistors and it worked fine from the 5V rail but the 7805 regulator just made the screen backlight continually flash on and off in short bursts and wasn't powering the RFID reader or PIC.

Not sure what's up with the regulator, it's an official texas instruments one, well, the packaging states it is anyway. Picture is rubbish but here's a pic of the regulators, the TI 7805, 2*NI LM2940's and a Motorola 7905;

 

I'm glad you solved your problem. Faulty hardware will do it every time. Now I recommend that you check your circuit to make sure you don't have a short. I have blown a voltage regulator or two that way. It never hurts to be too cautious.

 

Also if I ever need to make my eyes water and am lacking onions to slice, I will come back to this thread and look at that picture.

  • 0

I'm glad you solved your problem. Faulty hardware will do it every time. Now I recommend that you check your circuit to make sure you don't have a short. I have blown a voltage regulator or two that way. It never hurts to be too cautious.

 

Also if I ever need to make my eyes water and am lacking onions to slice, I will come back to this thread and look at that picture.

Haha the pics not THAT bad... well maybe it is...

I double checked and there is no short, it's using a PC power supply as the power source anyway and that automatically turns off supply power if there is a short (done it a few time accidentally on the 3.3V and 5V lines ;x).

This topic is now closed to further replies.
  • Posts

    • Ocenaudio 3.19.3 by Razvan Serea  Ocenaudio is a full featured, fast and easy to use audio and music editor. It is the ideal software for people who need to edit and analyze audio files without complications. Ocenaudio also has powerful features that will please more advanced users. To assist ocenaudio development, a powerful toolset of audio editing, analysis and manipulation called Ocen Framework was created. ocenaudio is also based on Qt framework, a well known library for cross-platform development. Cross-platform support ocenaudio is available for all major operating systems: Microsoft Windows, Mac OS X and Linux. Native applications are generated for each platform from a common source, in order to achieve excelent performance and seamless integration with the operating system. All versions of ocenaudio have a uniform set of features and the same graphical interface, so the skills you learn in one platform can be used in the others. VST plugins support Ocenaudio supports VST (Virtual Studio Technology) plugins, giving its users access to numerous effects. Like the native effects, VST effects can use real-time preview to aide configuration. Real-time preview of effects Applying effects such as EQ, gain and filtering is an important part of audio editing. However, it is very tricky to get the desired result by adjusting the controls configuration alone: you must listen the processed audio. To ease the configuration of audio effects, ocenaudio has a real time preview feature: you hear the processed signal while adjusting the controls. The effect configuration window also includes a miniature view of the selected audio signal. You can navigate on this miniature view in the same way as you do on the main interface, selecting parts that interest you and listening to the effect result in real time. Multiselection for delicate editions To speed up complex audio files editing, ocenaudio includes multi-selection. With this amazing tool, you can simultaneously select different portions of an audio file and listen, edit or even apply an effect to them. For example, if you want to normalize only the excerpts of an interview where the interviewee is talking, just select them and apply the effect. Eficient edition of large files With ocenaudio, there is no limit to the length or the quantity of the audio files you can edit. Using an advanced memory management system, the application keeps your files open without wasting any of your computer's memory. Even in files several hours long, common editing operations such as copy, cut or paste happen almost instantly. Fully featured spectrogram Besides offering an incredible waveform view of your audio files, ocenaudio has a powerful and complete spectrogram view. In this view, you can analyze the spectral content of your audio signal with maximum clarity. Advanced users will be surprised to find that the spectrogram settings are applied in real time. The display is updated immediately when altering features such as the number of frequency bands, window type and size and dynamic range of the display. Ocenaudio 3.19.3 changelog: Fixes issues with MP4 files with more than 8 channels Fixes incorrect VBR detection for some CBR MP3 files Other bug fixes and improvements Download: Ocenaudio 64-bit | Portable | ~40.0 MB (Freeware) Download: Ocenaudio for Linux and Mac OS View: Ocenaudio Homepage | Screenshot Get alerted to all of our Software updates on Twitter at @NeowinSoftware
    • DiskGenius 6.2.0.1829 - All Versions: Free, Lite & Portable by Razvan Serea DiskGenius is a full-featured partition manager, which is designed to optimize disk usage for Windows users. It will efficiently help you recover lost data, resize/split partition, backup files, edit hex data, check bad sectors, manage virtual disks, erase data, etc.. Create a system image backup for current Windows with simple clicks to keep the operating system under protection. DiskGenius key features: Partition Management - It can create format, resize, extend, backup, split, hide and clone partition, both MBR and GPT are supported. Disk and partition conversion - Convert dynamic disk to basic, convert virtual disk format and convert MBR to GPT, convert primary partition to logical. File recovery - It can recover files deleted or emptied form recycle bin, recover files from damaged partition or disk and recover files by file type and supports file preview and file filter. Partition recovery - It is the best partition recovery program in that it can recover files from damaged, corrupted and RAW partitions, search for lost partition and recover files from it, besides, it can fix partition table. RAID recovery - It can reconstruct Virtual RAID and recover files from it, and all RAID types are supported. Sector Editor - A Hex editor is embedded to help users edit raw hex data and recover data manually. Backup and Restore - It can backup and restore partition including system partition, hard disk and partition table. Bad Tracks - It can check and repair bad sectors for all storage devices; check hard disk S.M.A.R.T. information. Delete files permanently - It can delete files permanently so that they can't be recovered by any data recovery software. Virtual Disk - It supports virtual disks, including VMware, Virtual PC and Virtual Box. Create WinPE bootable disk and you can manage disk partition when system crashes or there is no operating system on your computer. Support FAT12/FAT16/FAt32/exFAT/NTFS/EXT2/EXT3/EXT4 file system format. DiskGenius 6.2.0.1829 changelog: Add the "Disk Speed Test" feature. Add the "Windows Boot Repair and Conversion" feature. Add the BMB21-2019 erase standard to the "Erase Sectors" feature. Add support for restoring an individual partition from a PMFX disk image file. Enhanced The "Verify Or Repair Bad Sectors/Blocks" feature displays disk read speed in the detection window during scanning. The "Quick Partition" dialog box allows users to quickly select the number of partitions by pressing the numeric keys 1, 2, 7, 8, or 9. The "Set Volume Name" dialog box supports selecting preset volume labels provided by the software. The "Copy Sectors" feature supports resuming copy tasks after modifying the number of skipped bad sectors. Add the "TRIM Optimization" option to the format dialog box. The "Clone Partition" and "Clone Disk" features perform TRIM optimization on target partitions or disks before cloning. Add support for Not Equal To search conditions (prefixed with "!") when searching hexadecimal data in the sector editor. Optimize the display of capacity values in the program interface to show two decimal places. Add a minimize button to dialogs that may require long processing time. Enhance support for the ReFS file system. Enhance support for newer HIF and MP4 formats when recovering files by type. Enhance support for the EXT4 file system. Enhance compatibility of the "File Recovery" feature with special data structures. Fixed Fixed the issue that the selected file system type automatically reverted to NTFS after changing it to exFAT or EXT4 in the "Quick Partition" dialog box. Fixed inaccurate Unicode string search results in the "Sector Editor" feature. Fixed the issue that exceptions might occur when adding multiple disks in the "Erase Sectors" feature. Fixed the issue that insufficient target disk space was incorrectly reported in some cases when cloning, backing up, or restoring disks. Fixed the issue that folder modification timestamps were not preserved when copying files from ReFS partitions. Fixed the issue that Excel-format reports generated by features such as file copying or bad sector checking could not be opened when the report contained more than one million rows. Fixed the issue that folders were not displayed in the exclude-folder dialog box when backing up partitions to image files. Fixed the issue that the "Erase Sectors" feature could not be executed in some cases. Download: DiskGenius 6.2.0.1829 | 63.9 MB (Freeware, paid upgrade available) Download: DiskGenius Portable 64-bit | 40.0 MB Download: DiskGenius Portable 32-bit | 36.0 MB Download: DiskGenius Lite 64-bit | 13.4 MB Download: DiskGenius Lite 32-bit | 11.6 MB View: DiskGenius Home Page | DiskGenius Screenshot Get alerted to all of our Software updates on Twitter at @NeowinSoftware
    • Really? Use a better search engine https://www.google.com/search?...ourceid=chrome&ie=UTF-8
  • Recent Achievements

    • Week One Done
      agatameier earned a badge
      Week One Done
    • One Month Later
      agatameier earned a badge
      One Month Later
    • Week One Done
      ssd21345 earned a badge
      Week One Done
    • Contributor
      MarkHughes4096 went up a rank
      Contributor
    • Dedicated
      jordanspringer earned a badge
      Dedicated
  • Popular Contributors

    1. 1
      +primortal
      513
    2. 2
      +Edouard
      182
    3. 3
      PsYcHoKiLLa
      143
    4. 4
      ATLien_0
      95
    5. 5
      Steven P.
      74
  • Tell a friend

    Love Neowin? Tell a friend!