Device configuration

(instructions, reset, WDT, specifications...) PIC17Cxx, PIC18Fxxx

Re: Device configuration

Postby Dimebag » Sun Jul 20, 2014 2:09 pm

Tom, I wasn't side tracked. I will move to PIC24/PIC32 after I understand C for embedded devices. I am asking for help to understand the basics of C/C++/Header/Linker/etc. I am looking at PIC24/PIC32 for later use. My knowledge base is very poor. In the meantime I just want to improve my understanding of the tech behind the complier. I understand the device I selected is out dated by the new MCU's standards. I am only asking for direction to advance my knowledge base.
Dimebag
 
Posts: 109
Joined: Sun Jun 29, 2014 7:51 am
Location: Sydney, Australia

Re: Device configuration

Postby Dimebag » Sun Jul 20, 2014 2:12 pm

PIC32 is of interest to me currently.
Dimebag
 
Posts: 109
Joined: Sun Jun 29, 2014 7:51 am
Location: Sydney, Australia

Re: Device configuration

Postby Dimebag » Sun Jul 20, 2014 2:15 pm

Updated code for 18F452 @ 20 mhz

Code: Select all
 #include <xc.h>

//Configurations and Fuses
#pragma config  OSC = HS, OSCS = OFF,PWRT = ON,BOR = OFF
#pragma config  BORV = 45,WDT = OFF,WDTPS = 1,CCP2MUX = OFF
#pragma config  STVR = OFF,LVP = OFF,DEBUG = OFF
#pragma config  CP0 = OFF,CP1 = OFF,CP2 = OFF,CP3 = OFF,CPB = OFF,CPD = OFF
#pragma config WRT0 = OFF,WRT1 = OFF,WRT2 = OFF,WRT3 = OFF,WRTB = OFF,WRTC = OFF,WRTD = OFF
#pragma config EBTR0 = OFF,EBTR1 = OFF,EBTR2 = OFF,EBTR3 = OFF,EBTRB = OFF

//PORTB pins.
char array[9] = {0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01};
//Timer values.
char offset[20] = {0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80,
                  0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01};

//char temp = 1;
char temp = 2;
int inside = 0;
int outside = 0;
int scanPin = 500;



void Initialization(void) {
    LATA = 0x00;
    LATB = 0X00;
    LATC = 0X00;
    LATD = 0X00;
    LATE = 0X00;

    TRISA = 0x00;
    TRISB = 0x00;
    TRISC = 0x00;
    TRISD = 0x00;
    TRISE = 0x00;

    PORTA = 0x00;
    PORTB = 0x00;
    PORTC = 0x00;
    PORTD = 0x00;
    PORTE = 0x00;
}

void delay(void) {

//inside-- is slower
//inside++ is faster
    for (inside = 0; inside > scanPin; inside++) {
         for (outside = 0; outside < temp; outside++) {
        // }
   //      for (inside = 0; inside < 5000; inside--) {
    }
}
}
void main(void) {
    Initialization(); //Set all device pins.
    //unsigned char array[9] = {0x80,0x40,0x20,0x10,0x08,0x04,0x02,0x01};
    while (1) {
        //    PORTB = offset--;
        PORTD = offset[0];//array[0];
        delay();

        PORTD = offset[1];//array[1];
        delay();

        PORTD = offset[2];//array[2];
        delay();

        PORTD = offset[3];//array[3];
        delay();

        PORTD = offset[4];//array[4];
        delay();

        PORTD = offset[5];//array[5];
        delay();

        PORTD = offset[6];//array[6];
        delay();

        PORTD = offset[7];//array[7];
        delay();

    }
}
 
Dimebag
 
Posts: 109
Joined: Sun Jun 29, 2014 7:51 am
Location: Sydney, Australia

Re: Device configuration

Postby Tom Maier » Sun Jul 20, 2014 2:49 pm

You need to get back to just blinking an LED or this will get out of hand. Ric suggested just using the built in __delay function that is in XC8, and that is a simple start.

Also, how are you seeing atmel parts as a compilation option?
User avatar
Tom Maier
Verified identity
 
Posts: 179
Joined: Mon May 26, 2014 2:37 pm
PIC experience: Professional 5+ years with MCHP products

Re: Device configuration

Postby Dimebag » Sun Jul 20, 2014 2:57 pm

how are you seeing atmel parts as a compilation option?
hahaha, that's what the guy behind the sales counter tried to sell me. I was not impressed.
Dimebag
 
Posts: 109
Joined: Sun Jun 29, 2014 7:51 am
Location: Sydney, Australia

Re: Device configuration

Postby Dimebag » Sun Jul 20, 2014 3:10 pm

You need to get back to just blinking an LED or this will get out of hand
I think I did do that. I am not sure if it would program to device that way. I am unable to show evidence. Please select a device in which I am able to provide code for Blinking led.
Dimebag
 
Posts: 109
Joined: Sun Jun 29, 2014 7:51 am
Location: Sydney, Australia

Re: Device configuration

Postby Dimebag » Sun Jul 20, 2014 3:15 pm

If your going to select PIC24/PIC32. I will need the fuse configuration declarations. I will need a sample code as well to support.
Dimebag
 
Posts: 109
Joined: Sun Jun 29, 2014 7:51 am
Location: Sydney, Australia

Re: Device configuration

Postby Tom Maier » Sun Jul 20, 2014 3:28 pm

You are being uncooperative, so I have to bail out here...
User avatar
Tom Maier
Verified identity
 
Posts: 179
Joined: Mon May 26, 2014 2:37 pm
PIC experience: Professional 5+ years with MCHP products

Re: Device configuration

Postby vloki » Sun Jul 20, 2014 8:48 pm

Tom Maier wrote:You are being uncooperative, so I have to bail out here...

+1 ;-)
vloki
Verified identity
 
Posts: 186
Joined: Wed May 28, 2014 8:42 am
Location: Germany
PIC experience: Professional 5+ years with MCHP products

Re: Device configuration

Postby Dimebag » Mon Jul 21, 2014 8:23 am

Hi Tom, I am waiting for the store to order some PIC24's, PIC32's. I will be hooking up a micro over the weekend to test the LED blinking program. At the moment I am using Proteus VSM to simulate the programs. BTW I have started using the delay_ms().
Dimebag
 
Posts: 109
Joined: Sun Jun 29, 2014 7:51 am
Location: Sydney, Australia

PreviousNext

Return to 16-Bit Core

Who is online

Users browsing this forum: No registered users and 7 guests

cron