2013-09-25

MPLAB X failed on PMP simulation

I just encountered a problem with Microchip's MPLAB X's simulator.

I wrote a very simple piece of program which switches values at the pin PMA0 (which is shared with RB15). The simulator just gave flat low.


I was so puzzled that I connected output pins to a logic analyzer. It showed that I was right and the simulator just didn't work correctly. The logic analyzer also gave me correct output if I set it to be always high or always low.


I am really disappointed about this bug, because it took me and my students hours. Even after I set the output on PMA0 to be constantly high, the virtual logic analyzer still gave me always low.




2013-09-24

Linux-Friendly EE Lab I: Oscilloscopes and Logic Analyzers

This is the first blog post of a series about how I set up my lab as a fresh faculty member in Electrical and Computer Engineering.

I am buying instruments for my lab. The first two I need are an oscilloscope and a logic analyzer.
 
First of all, I am a fan of computer-based instrumentation, like NI's stuff. However, I want a cheap solution to save money to pay my grad students- NI's DAQ cards are expensive. I also need a Linux-friendly solution - of course lots of NI's DAQ cards have Linux drivers and LabVIEW itself has native Linux version. Since I deal with physiological signals and low-frequency digital circuits, I do not have high demand on sampling rate nor bandwidth.

After a couple of hours of google searching, I found two that can fall into my expectation. They provide native Linux software, including driver programs.
PicoTech also offers a mixed-signal (2 analog inputs + 16 digital channels) oscilloscope at $575.

I also found out that many cheap Windows-only USB oscilloscopes/logic analyzer are really poorly made. Their GUIs suck. The two above that support Linux apparently have more functional GUIs. Also, those Windows-only solutions do not have good warranty and support. I have no idea about their return/refund policy.

    2013-09-10

    Checking correct maximum CPU frequency

    There are many tools in the world of Linux that allow checking the maximum CPU frequency. However, some of them may not tell you the correct one. I recently found out that cpufreq-aperf can give you the correct one. Other tools, such as cpufreq-info cannot get the information about Turbo Core for AMD CPUs.

    Using cpufreq-aperf is very simple:

    forrest@rootown:~/gits/mindboggle/mindboggle/utils$ cpufreq-aperf -o -i 10
    You must be root
    forrest@rootown:~/gits/mindboggle/mindboggle/utils$ sudo cpufreq-aperf -o -i 10
    [sudo] password for forrest: 
    Error reading /dev/cpu/0/msr, load/enable msr.ko
    forrest@rootown:~/gits/mindboggle/mindboggle/utils$ sudo modprobe msr
    forrest@rootown:~/gits/mindboggle/mindboggle/utils$ sudo cpufreq-aperf -o -i 10
    CPU Average freq(KHz) Time in C0 Time in Cx C0 percentage
    000 2438000   09 sec 978 ms 00 sec 021 ms 99
    001 2438000   09 sec 978 ms 00 sec 021 ms 99
    002 2438000   09 sec 976 ms 00 sec 023 ms 99
    003 2438000   09 sec 976 ms 00 sec 023 ms 99
    004 2438000   09 sec 976 ms 00 sec 023 ms 99
    005 2438000   09 sec 976 ms 00 sec 023 ms 99
    006 2438000   09 sec 976 ms 00 sec 023 ms 99
    007 2438000   09 sec 976 ms 00 sec 023 ms 99
    008 2438000   09 sec 978 ms 00 sec 021 ms 99
    009 2438000   09 sec 978 ms 00 sec 021 ms 99
    010 2438000   09 sec 976 ms 00 sec 023 ms 99
    011 2438000   09 sec 976 ms 00 sec 023 ms 99
    012 2438000   09 sec 976 ms 00 sec 023 ms 99
    013 2438000   09 sec 971 ms 00 sec 028 ms 99
    014 2438000   09 sec 976 ms 00 sec 023 ms 99
    015 2438000   09 sec 976 ms 00 sec 023 ms 99
    

    If Turbo Core is on, then you should see such frequency in freq column. Here, since I used all 16 cores, they all work at the label frequency.

    References:
    1. http://manpages.ubuntu.com/manpages/lucid/man1/cpufreq-aperf.1.html
    2. https://wiki.debian.org/HowTo/CpuFrequencyScaling
    3. https://wiki.archlinux.org/index.php/CPU_Frequency_Scaling