CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

Pin Assignment

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
littlewhitedot



Joined: 27 Nov 2016
Posts: 5

View user's profile Send private message

Pin Assignment
PostPosted: Fri Dec 09, 2016 9:10 pm     Reply with quote

Hi guys, I am a beginner in embedded programming. I was trying to port a library from https://www.research.ibm.com/labs/zurich/ics/lrsc/lmic.html into pic18lf46k22 but I am not sure how to.

This is the pin connection


and right now my code is:
Code:

#define NSS_PORT           TRISD
#define NSS_PIN            RD3
#define MISO_PORT          TRISD
#define MISO_PIN           RD1
#define MOSI_PORT          TRISD
#define MOSI_PIN           RD4
#define SCK_PORT           TRISD
#define SCK_PIN            RD0
#define RST_PORT           TRISC     
#define RST_PIN            RC2

#define DIO0_PORT          TRISB
#define DIO0_PIN           RB1
#define DIO1_PORT          TRISB
#define DIO1_PIN           RB0
#define DIO2_PORT          TRISB
#define DIO2_PIN           RB4
#define DIO3_PORT          TRISB
#define DIO3_PIN           RB3
#define DIO4_PORT          TRISB
#define DIO4_PIN           RB5
#define DIO5_PORT          TRISB
#define DIO5_PIN           RB0


I found the pic18lf46k22 header bitfield struct to be:
Code:

// Register: TRISA
extern volatile unsigned char           TRISA               @ 0xF92;
#ifndef _LIB_BUILD
asm("TRISA equ 0F92h");
#endif
// aliases
extern volatile unsigned char           DDRA                @ 0xF92;
#ifndef _LIB_BUILD
asm("DDRA equ 0F92h");
#endif
// bitfield definitions
typedef union {
    struct {
        unsigned TRISA0                 :1;
        unsigned TRISA1                 :1;
        unsigned TRISA2                 :1;
        unsigned TRISA3                 :1;
        unsigned TRISA4                 :1;
        unsigned TRISA5                 :1;
        unsigned TRISA6                 :1;
        unsigned TRISA7                 :1;
    };
    struct {
        unsigned RA0                    :1;
        unsigned RA1                    :1;
        unsigned RA2                    :1;
        unsigned RA3                    :1;
        unsigned RA4                    :1;
        unsigned RA5                    :1;
        unsigned RA6                    :1;
        unsigned RA7                    :1;
    };
} TRISAbits_t;


Am I doing this right? Please help me.
Ttelmah



Joined: 11 Mar 2010
Posts: 19541

View user's profile Send private message

PostPosted: Sat Dec 10, 2016 2:43 am     Reply with quote

Not really.

You need to step back and look at what the chip actually wants. It talks to it's host, using a UART. Standard serial. The two test pins you are trying to connect to, say on the data sheet 'do not connect'. If you look at Microchip's application note for this chip, they connect it to the TX and RX pins on the associated PIC.....
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group