PIC Development Board with PK3

hexreader

Joined Apr 16, 2011
581
Take great care with the 12V pins - if you connect +12 volts to almost any device on your board, that device will probably be killed - possibly even create smoke.

It is not necessarily 12 Volts anyway - depends on what voltage you feed in to the power connector.

If it were my board, I would cover the 12V pins to stop me accidently connecting when I don't want 12V.

12V supply might be handy for use with on-board relay/motor driver chip - but most of the time 12V will be unused.
 

Thread Starter

Djsarakar

Joined Jul 26, 2020
489
You're welcome.
That is actually a nice board. You should be able to try lots of cool things with no other hardware.
I do not understand how to connect 16 pins LCD because there is two columns CN13

Will the first column connect to PORT pins of MCU and other will connect to LCD pins ?
 

JohnInTX

Joined Jun 26, 2012
4,787
I do not understand how to connect 16 pins LCD because there is two columns CN13

Will the first column connect to PORT pins of MCU and other will connect to LCD pins ?
I think you should go back and make sure you can flash the LED at a specified rate using the button to turn the flashing on and off before tackling the LCD.
Make the debounce a function instead of inline.
Consider other button functions and the other LEDs.

You should resolve the flow chart and state machine stuff, too. The LCD init needs a particular sequence to start it up and that is given by a flow chart in the LCD datasheet. You need to demonstrate that you can construct, follow and code a flow chart / state machine before trying the LCD.

It took several threads and many posts to get to this point. Be sure you are ready to move on.
 

Thread Starter

Djsarakar

Joined Jul 26, 2020
489
There are 12 output pins from the module out of which 8 is used to display the characters and four is used to select one display out of four.

What is the DEC pin in seven segment module ?

1601397155677.png
 

Thread Starter

Djsarakar

Joined Jul 26, 2020
489
I am looking for the datasheet of JHD162A 659M10 LCD 16X2 for a long time . I have not been able to find the datasheet for 659M10.

Can anyone help me to find correct datasheet..
 

JohnInTX

Joined Jun 26, 2012
4,787
Last edited:

Thread Starter

Djsarakar

Joined Jul 26, 2020
489
What's the delay timer 0 gives with 1: 256 presale value ?

Fosc/4 with an 8MHz clock, that is 2000000Hz.

//T1CON: TIMER1 CONTROL REGISTER
TMR0ON = 1; //Timer0 On
T08BIT = 1; // Timer0 is configured as an 8-bit timer/counter0
T0CS = 0; // Internal instruction cycle clock (CLKO)
T0SE = 1; //Increments on high-to-low transition on T0CKI pin0
PSA = 0; //Timer0 prescaler is assigned; Timer0 clock input comes from prescaler output
//1:8 Prescale value
T0PS2 = 1;
T0PS1 = 1;
T0PS0 = 1;

TMR0L = ? ; //Timer0 Register Low Byte
TMR0H =? ; //Timer0 Register High Byte
 

JohnInTX

Joined Jun 26, 2012
4,787
Your question has some contradictions. If running 8 bits, you don't use TMR0H. One comment says 1:8 prescale, another says 1:256. Settings are for 256.
Not sure what you are asking but the calculation is similar to MODE 0 in the 8051. Why not try a sample calculation and show your work?
 

Thread Starter

Djsarakar

Joined Jul 26, 2020
489
Why not try a sample calculation and show your work?
Fosc/4 with an 8MHz clock, that is 2000000Hz.
1: 256 presale value , 8 bit prescaler

1/8000000/256 = 7813 Hz

12.799 uSeconds/Count

1000us / 12.799 uSeconds/Count

78 counts

256-78 = 178 value

TMR0L = 0 ; //Timer0 Register Low Byte
TMR0H = 178 ; //Timer0 Register High Byte
 

JohnInTX

Joined Jun 26, 2012
4,787
For your 1ms timer setting I get:
8Mhz Fosc / 4 = 2Mhz Tcyc (frequency into TIMER 0)
2Mhz = 500ns period.
500ns *256 Prescaler = 128uS (TMR0 clock period)
1000uS / 128 uS = 7.8125 round to 8 (TMR0 periods to count)
256 - 8 = 248
TMR0L = 248
TMR0H is NOT USED IN 8 BIT TIMER MODE
 

jpanhalt

Joined Jan 18, 2008
11,087
Fosc/4 with an 8MHz clock, that is 2000000Hz.
1: 256 presale value , 8 bit prescaler

1/8000000/256 = 7813 Hz
Please show your math ... or get a new calculator.

Why did you choose to use 8,000,000 as the dividend instead of 2,000,000 that you calculated in the first step?
 

Thread Starter

Djsarakar

Joined Jul 26, 2020
489
For your 1ms timer setting I get:
8Mhz Fosc / 4 = 2Mhz Tcyc (frequency into TIMER 0)
2Mhz = 500ns period.
500ns *256 Prescaler = 128uS (TMR0 clock period)
1000uS / 128 uS = 7.8125 round to 8 (TMR0 periods to count)
256 - 8 = 248
TMR0L = 248
TMR0H is NOT USED IN 8 BIT TIMER MODE
I am posting my code. simulator gives 776. 5us. Can you tell me by running code on simulator. how much time simulator gives

C:
#define _XTAL_FREQ 8000000
#include <xc.h>
// PIC18F45K80 Configuration Bit Settings
// 'C' source line config statements
// CONFIG1L
#pragma config RETEN = OFF      // VREG Sleep Enable bit (Ultra low-power regulator is Disabled (Controlled by REGSLP bit))
#pragma config INTOSCSEL = HIGH // LF-INTOSC Low-power Enable bit (LF-INTOSC in High-power mode during Sleep)
#pragma config SOSCSEL = HIGH   // SOSC Power Selection and mode Configuration bits (High Power SOSC circuit selected)
#pragma config XINST = OFF       // Extended Instruction Set (Enabled)
// CONFIG1H
#pragma config FOSC = INTIO2    // Oscillator (Internal RC oscillator)
#pragma config PLLCFG = OFF     // PLL x4 Enable bit (Disabled)
#pragma config FCMEN = OFF      // Fail-Safe Clock Monitor (Disabled)
#pragma config IESO = OFF       // Internal External Oscillator Switch Over Mode (Disabled)
// CONFIG2L
#pragma config PWRTEN = OFF     // Power Up Timer (Disabled)
#pragma config BOREN = SBORDIS  // Brown Out Detect (Enabled in hardware, SBOREN disabled)
#pragma config BORV = 3         // Brown-out Reset Voltage bits (1.8V)
#pragma config BORPWR = ZPBORMV // BORMV Power level (ZPBORMV instead of BORMV is selected)
// CONFIG2H
#pragma config WDTEN = OFF      // Watchdog Timer (WDT disabled in hardware; SWDTEN bit disabled)
#pragma config WDTPS = 1048576  // Watchdog Postscaler (1:1048576)
// CONFIG3H
#pragma config CANMX = PORTB    // ECAN Mux bit (ECAN TX and RX pins are located on RB2 and RB3, respectively)
#pragma config MSSPMSK = MSK7   // MSSP address masking (7 Bit address masking mode)
#pragma config MCLRE = ON       // Master Clear Enable (MCLR Enabled, RE3 Disabled)
// CONFIG4L
#pragma config STVREN = ON      // Stack Overflow Reset (Enabled)
#pragma config BBSIZ = BB2K     // Boot Block Size (2K word Boot Block size)
// CONFIG5L
#pragma config CP0 = OFF        // Code Protect 00800-01FFF (Disabled)
#pragma config CP1 = OFF        // Code Protect 02000-03FFF (Disabled)
#pragma config CP2 = OFF        // Code Protect 04000-05FFF (Disabled)
#pragma config CP3 = OFF        // Code Protect 06000-07FFF (Disabled)
// CONFIG5H
#pragma config CPB = OFF        // Code Protect Boot (Disabled)
#pragma config CPD = OFF        // Data EE Read Protect (Disabled)
// CONFIG6L
#pragma config WRT0 = OFF       // Table Write Protect 00800-01FFF (Disabled)
#pragma config WRT1 = OFF       // Table Write Protect 02000-03FFF (Disabled)
#pragma config WRT2 = OFF       // Table Write Protect 04000-05FFF (Disabled)
#pragma config WRT3 = OFF       // Table Write Protect 06000-07FFF (Disabled)
// CONFIG6H
#pragma config WRTC = OFF       // Config. Write Protect (Disabled)
#pragma config WRTB = OFF       // Table Write Protect Boot (Disabled)
#pragma config WRTD = OFF       // Data EE Write Protect (Disabled)
// CONFIG7L
#pragma config EBTR0 = OFF      // Table Read Protect 00800-01FFF (Disabled)
#pragma config EBTR1 = OFF      // Table Read Protect 02000-03FFF (Disabled)
#pragma config EBTR2 = OFF      // Table Read Protect 04000-05FFF (Disabled)
#pragma config EBTR3 = OFF      // Table Read Protect 06000-07FFF (Disabled)
// CONFIG7H
#pragma config EBTRB = OFF      // Table Read Protect Boot (Disabled)


#define Port_Pin           LATBbits.LATB0


volatile int Count = 0;

void Port_pins_Initialized (void);
void Timer0_Initialized (void);
void __interrupt(high_priority) tcInt(void);


void main(void)
{

    Timer0_Initialized ();
    Port_pins_Initialized ();

    while (1)
    {
    }
}


void Port_pins_Initialized (void)
{
    LATA = LATB = LATC = LATD = LATE =  0;

    TRISA = 0b0000000;// all are output, Unused
    TRISB = 0b0000000;// B0 To LED1, B1 To LED2, B2 To LED3 and B3 To LED4
    TRISC = 0b0000000;// all are output, Unused
    TRISD = 0b0000000;//  All are output, Unused
    TRISE = 0b0000000;// All are output, Unused

    ANCON0 = 0; // digital port
    ANCON1 = 0; // digital port
    CM1CON = 0; // Comparator off
    CM2CON = 0; // Comparator off
    ADCON0 = 0; // A/D conversion Disabled
}

void Timer0_Initialized (void)
{
     TMR0L = 248;    //Timer0 Register Low Byte

    //T1CON: TIMER1 CONTROL REGISTER
     TMR0ON = 1; //Timer0 On
     T08BIT = 1; // Timer0 is configured as an 8-bit timer/counter0
     T0CS = 0;   // Internal instruction cycle clock (CLKO)
     T0SE = 1;    //Increments on high-to-low transition on T0CKI pin0
     PSA = 0; //Timer0 prescaler is assigned; Timer0 clock input comes from prescaler output
     //1:8 Prescale value
     T0PS2 = 1;
     T0PS1 = 1;
     T0PS0 = 1;

     //INTCON: INTERRUPT CONTROL
     GIE = 1;    // Enable Global Interrupt Enable bit
        PEIE = 0;   //Disables all peripheral interrupts
     TMR0IE = 1; //Enables the TMR0 overflow interrupt
     INT0IE = 0; //Disables the INT0 external interrupt
     RBIE = 0; //Disables the RB port change interrupt
     TMR0IF = 0;// cleared timer overflow flag
     INT0IF = 0; // disabled external interrupt
     RBIF = 0; //disabled Port Change Interrupt Flag bit

     PMD1 = 0b00000000;
}

void __interrupt(high_priority) tcInt(void)
{
  if (TMR0IF == 1) // Timer0 overflow interrupt flag bit
  {
      Port_Pin  =~ Port_Pin;
  }

    TMR0L = 248;    //Timer0 Register Low Byte 
    TMR0IF = 0;
  }
1601552013388.png
 
Last edited:
Top