Author Topic: Dropshot With LT cancel 12f1822 help  (Read 2191 times)

Offline cduryee

  • Guppy
  • *
  • Posts: 3
  • Post quality +0/-0
  • Gender: Male
  • Acidmods User
Dropshot With LT cancel 12f1822 help
« on: January 25, 2014, 06:20:07 AM »
I have been racking my brain with trying to develop some code in basic c using mplab with xc8. Actually this will hopefully be my first time completing an application. I'm of course am trying to  use pic 12f1822. Now my problem is figuring everything out lol~!
I've started but definitely am a little lost. First question would be for LT and  RT when depressed should I be trying to use falling edge detection or just pin low then start my if then routines for B button press which would then  have PORTA RA of choice  Pin go low.

I willing to post up some of my new amateurish start to coding up. Any help would be appreciated
P.S. My goal right now is to simply make Xbox 1 Lt cancel dropshot  1 mode on 1 mode off with mode button. Then maybe later add modes for, RF with DS Lt cancel. It just depends if I can pick this up.

Do I need Ansel or a/d converter for trigger detection. Like set to analog input?
Things I do know: need GIE, WPUA for button press
Lots of things where I'm kinda lost.. Button debounce routine, Interrupts, Should Lt press cause Interrupt routine. Meanwhile main routine still running checking for flag bit whether its cleared or not to determine whether or not the LT trigger is depressed or not and if it should run the subroutine which would be Pin whatever going low for b button depress and another question should be button simulated as two consecutive button presses to hit the deck or just one extra long press 750 + _delay_(750ms). Anyways I'm done for now just rambling on. So thanks for reading.
« Last Edit: January 26, 2014, 03:24:31 AM by cduryee »

Offline SethMods

  • Registered BST
  • King of the Wii-tards
  • *
  • Posts: 189
  • Post quality +17/-1
  • Gender: Male
  • Acidmods User
Re: Dropshot With LT cancel 12f1822
« Reply #1 on: January 25, 2014, 07:15:01 AM »
All great questions. Help us out with your hardware setup.

What controller is this for? Wireless? CG1, CG2, Matrix, Matrix2?


Also, what is your pin layout? (What pin goes to what?)

And how do you plan to switch modes?

Offline cduryee

  • Guppy
  • *
  • Posts: 3
  • Post quality +0/-0
  • Gender: Male
  • Acidmods User
Re: Dropshot With LT cancel 12f1822
« Reply #2 on: January 25, 2014, 08:09:10 AM »
Hey Seth,
Thanks for the response. I'm shooting for the Xbox 1 controller and my pin layout is tentative on how this may turn out.
Right now here is my recent start on this. RAW but this is where I'm at:

//******************* ****************************************************************
 *
 * Pin Assignments
 * VDD PIN 1 Power
 * VSS PIN 8 Ground
 * RA5 PIN 2 A Button @ a Later Date //Hope to add function later..
 * RA4 PIN 3 LT Button
 * RA0 PIN 7 B Button
 * RA1 PIN 6 RT Button         
 * RA2 PIN 5 LED
 * RA3 PIN 4 MOD Button **SYNC BUTTON, BUTTON To GND, ETC..
 * ***************************************************************
 * /

 #include <pic12f1822>
 #include <stdint.h>
 #include <stdlib.h>
 #include <xc.h>
 #define _XTAL_FREQ    4000000     // Osc Freq for _delay()
/**Configuration**/
 // CONFIG1
#include <xc.h>
#pragma config FOSC = INTOSC    // Oscillator Selection (INTOSC oscillator: I/O function on CLKIN pin)
#pragma config WDTE = OFF       // Watchdog Timer Enable (WDT disabled)
#pragma config PWRTE = OFF      // Power-up Timer Enable (PWRT disabled)
#pragma config MCLRE = OFF      // MCLR Pin Function Select (MCLR/VPP pin function is digital input)
#pragma config CP = OFF         // Flash Program Memory Code Protection (Program memory code protection is disabled)
#pragma config CPD = OFF        // Data Memory Code Protection (Data memory code protection is disabled)
#pragma config BOREN = OFF      // Brown-out Reset Enable (Brown-out Reset disabled)
#pragma config CLKOUTEN = OFF   // Clock Out Enable (CLKOUT function is disabled. I/O or oscillator function on the CLKOUT pin)
#pragma config IESO = ON        // Internal/External Switchover (Internal/External Switchover mode is enabled)
#pragma config FCMEN = ON       // Fail-Safe Clock Monitor Enable (Fail-Safe Clock Monitor is enabled)

// CONFIG2
#pragma config WRT = OFF        // Flash Memory Self-Write Protection (Write protection off)
#pragma config PLLEN = ON       // PLL Enable (4x PLL enabled)
#pragma config STVREN = ON      // Stack Overflow/Underflow Reset Enable (Stack Overflow or Underflow will cause a Reset)
#pragma config BORV = LO        // Brown-out Reset Voltage Selection (Brown-out Reset Voltage (Vbor), low trip point selected.)
#pragma config LVP = OFF         // Low-Voltage Programming Enable (Low-voltage programming enabled)

/**MAIN PROGRAM**/
void main(void)
{
    //****Initializaion
    OSCCONbits.IRCF = 0b1101        //4MHz
    OPTION_REGbits.nWPUEN = 0;  ///enable weak pull ups (global)
    WPUAbits.WPUA3        = 1;      //ENABLE ra3 pullup
    WPUA = 1<<3;                //enable pull up RA3 only
    // Configure Ports
    LATA = 0;
    TRISA = 0b00011110;  // Only RA1, RA2 tO start with, RA3, AND RA4 as Input PINS 3,4,5,6
    PORTA = 0b00000000;  // All Pins Set to low
    ANSELA = 0b00001000; // Set RA3 as Digital input
// Led Blink DS
    TRISA.bitsTRISA2 = 0;
    delay_ms(400)
    TRISA.bitsTRISA2 = 1;
   
    //**Main Loop**
    for (;;)
    {                        //loop forever
            ;
    }
« Last Edit: January 26, 2014, 07:01:38 AM by cduryee »

 

SMF spam blocked by CleanTalk
SimplePortal 2.3.5 © 2008-2012, SimplePortal