AOA Forums

AOA Forums (
-   Hardware Hacking (
-   -   MPLAB SIM and Alternate pin function!? (

Aedan 25th January, 2010 06:51 PM

MPLAB SIM and Alternate pin function!?
I'm throwing this out to see if anyone else can make sense of this...

Some background: I'm "playing" around with a PIC 12F615 microcontroller. Ultimately, if I can make it do what I want it to do, it'll control a remote control toy. I've written a fair bit of code that works in a simulator. Except for one small part. As the "user interface" of the device is actually an IR transmitter, I need to be able to receive IR pulses. The code I'm using is using one of the timers to time how long a pulse is, in order to determine if it's a zero or a one.

Due to the way the pins are set up, I need to use an alternate pin function for timer 1 gate (T1G). However, when I try this in the simulator (MPLAB SIM), it doesn't appear to work how I expect it to work. A small sample of code is below:


; Alt !T1G Testing
        #include <P12F615.INC>
        __CONFIG h'3CD4'
        org 0
; IO Port Setup
; T1G is GPIO4
        BANKSEL        ANSEL
        CLRF        ANSEL                ; Digital I/O, ADC off.

; Timer1 gate setup
        ; !T1G is normally GP4
        ; Select alt !T1G - GP3 input
        BANKSEL        APFCON
        BSF                APFCON,T1GSEL

        BANKSEL        T1CON
        MOVLW        b'11000001'        ; Gate active high and enabled, timer on
        MOVWF        T1CON                ; Let's go!

        GOTO $                                ; And go...

Am I just stupid, or is something else going on here? All the software needed can be downloaded for free from this page: MPLAB Integrated Development Environment.

Gizmo 26th January, 2010 12:21 AM

Perhaps this is one of those corner-cases where the hardware behaves slightly different than the emulator?

Too bad they chose to write their own IDE (that is windows-only) rather than a plugin to Eclipse.

Aedan 26th January, 2010 10:46 AM

I'm presuming that it must be bug in the SIM. Too bad, as I was hoping to test out my IR reception code to ensure it works as designed! I didn't want to have build a test rig to check things out, but I guess I will have to do so!

Aedan 26th January, 2010 07:09 PM

The Linux simulators haven't yet caught up with the devices I'm using, but MPLab does run fairly well under wine. As far as MPLAB goes, the majority of their software can be called from the command line, but not the simulator.

All times are GMT +1. The time now is 06:53 PM.

Copyright ©2001 - 2010, AOA Forums

Search Engine Friendly URLs by vBSEO 3.3.0