Device configuration

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

Re: Device configuration

Postby Tom Maier » Fri Jul 18, 2014 3:19 pm

The compiler generates assembly language code, which the make file passes to the linker and assembler programs, and then it becomes cooked down to a hex file. You can read the assembly that is produced and count the cycles, but then since you don't know assembly that might just be a deep rabbit hole you should save for later. Eventually that would be a good skill. At first, just get an LED blinking.

So you have a scope or frequency counter? You will eventually need one if you are going to do much in embedded. If you toggle a pin in your loop you can see the loop speed.

I've never used the pic you are using, so I don't have a nice header to dump on you. Anybody out there got a simple header for this chip in XC8?
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 » Sat Jul 19, 2014 5:46 am

I have an oscilloscope already. I did own a frequency/counter generator, but my old flat mate stole it. The reason I don't use PIC24, or PIC32 is because I am not very good at soldering SMD's at the moment. A little bit touch and go with them.
Dimebag
 
Posts: 109
Joined: Sun Jun 29, 2014 7:51 am
Location: Sydney, Australia

Re: Device configuration

Postby ric » Sat Jul 19, 2014 6:01 am

Note, there are a number of PIC32 parts available in a 28 pin DIP package.
Latest test project, an LED matrix display made from one reel of addressable LEDs. here
User avatar
ric
Verified identity
 
Posts: 659
Joined: Sat May 24, 2014 2:35 pm
Location: Melbourne, Australia
PIC experience: Professional 5+ years with MCHP products

Re: Device configuration

Postby Dimebag » Sat Jul 19, 2014 6:30 am

I think I found the generated code thing. "Unable to generate the disassembly listing file. Please make sure that you have built the project with symbol information." now what should I do?
Dimebag
 
Posts: 109
Joined: Sun Jun 29, 2014 7:51 am
Location: Sydney, Australia

Re: Device configuration

Postby ric » Sat Jul 19, 2014 6:35 am

I've not used XC8 yet, I'm still using Hitech C.
I think you need to uncheck a box in the compiler settings for "delete temporary files after compilation".
By default it deletes the files containing the assembly language source once the hex file has been created.
Latest test project, an LED matrix display made from one reel of addressable LEDs. here
User avatar
ric
Verified identity
 
Posts: 659
Joined: Sat May 24, 2014 2:35 pm
Location: Melbourne, Australia
PIC experience: Professional 5+ years with MCHP products

Re: Device configuration

Postby Dimebag » Sat Jul 19, 2014 7:05 am

Can someone post an example of this generated assembly code.
Dimebag
 
Posts: 109
Joined: Sun Jun 29, 2014 7:51 am
Location: Sydney, Australia

Re: Device configuration

Postby ric » Sat Jul 19, 2014 9:53 am

Here you go.
This was the source file, which is your code with some slight additions to let it compile
Code: Select all
#include <xc.h>

//Statement covering the start up output and input pins of Device.
void Initialization(void)
{
    TRISB = 0;  //set all pins to output
}

void pivit_2(void) {
    PORTB = 0x55;
}

void main(void) {
    Initialization();
   
    while (1) { //running code goes inside this loop
        for (int f = 4000; f > 0; f--);  //int f = 0;

        pivit_2();
        {
        }
    }
}

The project is at C:\Users\Ric\MPLABXProjects\test-xc8.X
and this file is C:\Users\Ric\MPLABXProjects\test-xc8.X\dist\default\production\test-xc8.X.production.lst
Attachments
test-xc8.X.production.lst
(16.68 KiB) Downloaded 292 times
Latest test project, an LED matrix display made from one reel of addressable LEDs. here
User avatar
ric
Verified identity
 
Posts: 659
Joined: Sat May 24, 2014 2:35 pm
Location: Melbourne, Australia
PIC experience: Professional 5+ years with MCHP products

Re: Device configuration

Postby Dimebag » Sun Jul 20, 2014 3:14 am

I am testing this code at the moment. All of PORTB is meant to flash. I am trying to work out how to get the pins on portb to flash one at a time. Later on have some pins on PORTB flash faster than other pins

Code: Select all
void delay(void) {

    for (inside = 0; inside < 5000; inside++) {
        for (outside = 0; outside < 12; outside++) {
        }
    }
}

void main(void) {
    Initialization(); //Set all device pins.
   
    while (1) {
        PORTB = offset--;
        delay();

        PORTB = offset++;
        delay();
Dimebag
 
Posts: 109
Joined: Sun Jun 29, 2014 7:51 am
Location: Sydney, Australia

Re: Device configuration

Postby Dimebag » Sun Jul 20, 2014 6:08 am

A little bit better using an array.
Code: Select all
void delay(void) {

    for (inside = 0; inside < 4000; inside++) {
        for (outside = 0; outside < 1; outside++) {
        }
    }
}

void main(void) {
    Initialization(); //Set all device pins.
    //char array[9] = {0x80,0x40,0x20,0x10,0x08,0x04,0x02,0x01};
    while (1) {
        //    PORTB = offset--;
        PORTB = array[0];
        delay();

        PORTB = array[1];
        delay();

        PORTB = array[2];
        delay();

        PORTB = array[3];
        delay();

        PORTB = array[4];
        delay();

        PORTB = array[5];
        delay();

        PORTB = array[6];
        delay();

        PORTB = array[7];
        delay();

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

Re: Device configuration

Postby Dimebag » Sun Jul 20, 2014 11:37 am

Post by Tom Maier » Fri Jul 18, 2014 10:19 am

The compiler generates assembly language code, which the make file passes to the linker and assembler programs, and then it becomes cooked down to a hex file. You can read the assembly that is produced and count the cycles, but then since you don't know assembly that might just be a deep rabbit hole you should save for later. Eventually that would be a good skill. At first, just get an LED blinking.

Thank you Tom. You are totally correct I am not be able to understand "Generated Assembly Language code" at this stage of development.
I didn't really understand assembly code. I am not sure I am showing any signs of improvement. Google searching this subject has given mixed results.
Please look at the code I have given. I have used the available resources that I have been able to find
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 9 guests

cron