ISELED Easy EVB Microchip.pdf
0.10MB
ISELED Design Guide_MicrochipKorea_A01_20220624_KR.pdf
1.06MB
seddLED3-0 A3A-FKG - v3.pdf
1.89MB

 

Posted by KennyShin
,

- 명성과 브랜드를 보호하기 위해서

- 해킹을 차단하기 위해서

- 기밀성, 무결성 및 가용성 보장

Posted by KennyShin
,

- 안전한 프로그램 공간

- 하드웨어 영구 보안 영역

- 잘 설계된 에코시스템 및 인프라

Posted by KennyShin
,

/**
  MEMORY Generated Driver File

  @Company
    Microchip Technology Inc.

  @File Name
    memory.c

  @Summary
    This is the generated driver implementation file for the MEMORY driver using PIC10 / PIC12 / PIC16 / PIC18 MCUs

  @Description
    This file provides implementations of driver APIs for MEMORY.
    Generation Information :
        Product Revision  :  PIC10 / PIC12 / PIC16 / PIC18 MCUs - 1.81.7
        Device            :  PIC18F25K80
        Driver Version    :  2.04
    The generated drivers are tested against the following:
        Compiler          :  XC8 2.31 and above
        MPLAB             :  MPLAB X 5.45
*/

/*
    (c) 2018 Microchip Technology Inc. and its subsidiaries. 
    
    Subject to your compliance with these terms, you may use Microchip software and any 
    derivatives exclusively with Microchip products. It is your responsibility to comply with third party 
    license terms applicable to your use of third party software (including open source software) that 
    may accompany Microchip software.
    
    THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, WHETHER 
    EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, INCLUDING ANY 
    IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, AND FITNESS 
    FOR A PARTICULAR PURPOSE.
    
    IN NO EVENT WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, 
    INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND 
    WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP 
    HAS BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO 
    THE FULLEST EXTENT ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL 
    CLAIMS IN ANY WAY RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT 
    OF FEES, IF ANY, THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS 
    SOFTWARE.
*/

/**
  Section: Included Files
*/

#include <xc.h>
#include "memory.h"


/**
  Section: Flash Module APIs
*/

uint8_t FLASH_ReadByte(uint32_t flashAddr)
{
    TBLPTRU = (uint8_t)((flashAddr & 0x00FF0000) >> 16);
    TBLPTRH = (uint8_t)((flashAddr & 0x0000FF00)>> 8);
    TBLPTRL = (uint8_t)(flashAddr & 0x000000FF);

    asm("TBLRD");

    return (TABLAT);
}

uint16_t FLASH_ReadWord(uint32_t flashAddr)
{
    return ((((uint16_t)FLASH_ReadByte(flashAddr+1))<<8)|(FLASH_ReadByte(flashAddr)));
}

void FLASH_WriteByte(uint32_t flashAddr, uint8_t *flashRdBufPtr, uint8_t byte)
{
    uint32_t blockStartAddr = (uint32_t)(flashAddr & ((END_FLASH-1) ^ (ERASE_FLASH_BLOCKSIZE-1)));
    uint8_t offset = (uint8_t)(flashAddr & (ERASE_FLASH_BLOCKSIZE-1));
    uint8_t i;

    // Entire row will be erased, read and save the existing data
    for (i=0; i<ERASE_FLASH_BLOCKSIZE; i++)
    {
        flashRdBufPtr[i] = FLASH_ReadByte((blockStartAddr+i));
    }

    // Load byte at offset
    flashRdBufPtr[offset] = byte;

    // Writes buffer contents to current block
    FLASH_WriteBlock(blockStartAddr, flashRdBufPtr);
}

int8_t FLASH_WriteBlock(uint32_t writeAddr, uint8_t *flashWrBufPtr)
{
    uint32_t blockStartAddr  = (uint32_t )(writeAddr & ((END_FLASH-1) ^ (ERASE_FLASH_BLOCKSIZE-1)));
    uint8_t GIEBitValue = INTCONbits.GIE;     // Save interrupt enable
    uint8_t i, j, numberOfWriteBlocks;
    uint16_t WriteBlkOffset = 0;
    
    // Flash write must start at the beginning of a row
    if(writeAddr != blockStartAddr)
    {
        return -1;
    }
    
    // Total number of write blocks present in one erase block
    numberOfWriteBlocks = ERASE_FLASH_BLOCKSIZE/WRITE_FLASH_BLOCKSIZE;   

    // Block erase sequence
    FLASH_EraseBlock(writeAddr); 

    for(j=0; j<numberOfWriteBlocks; j++)
    {
        // Calculate starting offset of Write Block
        WriteBlkOffset = (uint16_t)j * WRITE_FLASH_BLOCKSIZE;
        
        // Block Write sequence
        TBLPTRU = (uint8_t)(((writeAddr + WriteBlkOffset) & 0x00FF0000) >> 16);    // Load Table point register
        TBLPTRH = (uint8_t)(((writeAddr + WriteBlkOffset) & 0x0000FF00) >> 8);
        TBLPTRL = (uint8_t)((writeAddr + WriteBlkOffset) & 0x000000FF);
    
        for (i=0; i<WRITE_FLASH_BLOCKSIZE; i++)
        {
            TABLAT = flashWrBufPtr[WriteBlkOffset+i];  // Load data byte

            if (i == (WRITE_FLASH_BLOCKSIZE-1))
            {
                asm("TBLWT");
            }
            else
            {
                asm("TBLWTPOSTINC");
            }
        }
        
        EECON1bits.WREN = 1;
        INTCONbits.GIE = 0; // Disable interrupts
        EECON2 = 0x55;
        EECON2 = 0xAA;
        EECON1bits.WR = 1;  // Start program

        EECON1bits.WREN = 0;    // Disable writes to memory
        INTCONbits.GIE = GIEBitValue;   // Restore interrupt enable
    }

    return 0;
}

void FLASH_EraseBlock(uint32_t baseAddr)
{
    uint8_t GIEBitValue = INTCONbits.GIE;   // Save interrupt enable

    TBLPTRU = (uint8_t)((baseAddr & 0x00FF0000) >> 16);
    TBLPTRH = (uint8_t)((baseAddr & 0x0000FF00)>> 8);
    TBLPTRL = (uint8_t)(baseAddr & 0x000000FF);

    EECON1bits.EEPGD = 1;
    EECON1bits.CFGS = 0;
    EECON1bits.WREN = 1;
    EECON1bits.FREE = 1;
    INTCONbits.GIE = 0; // Disable interrupts
    EECON2 = 0x55;
    EECON2 = 0xAA;
    EECON1bits.WR = 1;
    INTCONbits.GIE = GIEBitValue;   // Restore interrupt enable
}

/**
  Section: Data EEPROM Module APIs
*/

void DATAEE_WriteByte(uint16_t bAdd, uint8_t bData)
{
    uint8_t GIEBitValue = INTCONbits.GIE;

    EEADRH = ((bAdd >> 8) & 0x03);
    EEADR = (bAdd & 0xFF);
    EEDATA = bData;
    EECON1bits.EEPGD = 0;
    EECON1bits.CFGS = 0;
    EECON1bits.WREN = 1;
    INTCONbits.GIE = 0;     // Disable interrupts
    EECON2 = 0x55;
    EECON2 = 0xAA;
    EECON1bits.WR = 1;
    // Wait for write to complete
    while (EECON1bits.WR)
    {
    }

    EECON1bits.WREN = 0;
    INTCONbits.GIE = GIEBitValue;   // restore interrupt enable
}

uint8_t DATAEE_ReadByte(uint16_t bAdd)
{
    EEADRH = ((bAdd >> 8) & 0x03);
    EEADR = (bAdd & 0xFF);
    EECON1bits.CFGS = 0;
    EECON1bits.EEPGD = 0;
    EECON1bits.RD = 1;
    NOP();  // NOPs may be required for latency at high frequencies
    NOP();

    return (EEDATA);
}

void MEMORY_Tasks( void )
{
    /* TODO : Add interrupt handling code */
    PIR4bits.EEIF = 0;
}
/**
 End of File
*/

Posted by KennyShin
,

PIC16F1828_StartUp.X.zip
0.10MB

 

Microchip

 

PIC16F1828 powerup.as powerup.S

Example code

 

I used the powerup.as or powerup.S below path

C:\Program Files\Microchip\xc8\v2.30\pic\sources\c90\pic

 

you can find the path when you install MPLAB XC8 Compiler

 

Below link will also help when you make powerup.as or powerup.S

 

microchipdeveloper.com/xc8:powerup-routine

 

 

Thank you!

 

 

 

 

; XC8 PIC powerup routine
;
; This module may be modified to include custom code to be executed 
; immediately after reset. After performing whatever powerup code
; is required, it should jump to "start"

#include "aspic.h"

global powerup,start
psect powerup,class=CODE,delta=2
powerup:

;
; Insert special powerup code here
;
;


; Now lets jump to start 
#if defined(_PIC14)
clrf STATUS
movlw start>>8
movwf PCLATH
goto start & 0x7FF | (powerup & not 0x7FF)
#endif
#if defined(_PIC14E) || defined(_PIC14EX)
clrf STATUS
movlp start>>8
goto start & 0x7FF | (powerup & not 0x7FF)
#endif
#if defined(_PIC16)
movlw start>>8
movwf PCLATH
movlw start & 0xFF
movwf PCL
#endif
end

Posted by KennyShin
,

This is the example source code for the Cyclic Redundancy Check (CRC) Module with Memory Scanner

(Microchip microcontroller)

 

volatile unsigned int crc = 0;
const uint8_t data[2] __at(0x800) = {0x6C, 0x93};

unsigned char data_size = 0;
unsigned char data_index = 0;

void main(void)
{
    // initialize the device
    SYSTEM_Initialize();
    
    SCANCON0bits.EN = 1;
    SCANCON0bits.MODE = 0;
    SCANCON0bits.INTM = 0;
    SCANLADR = 0x800;
    SCANHADR = 0x801;
    
  
    CRCCON0bits.EN = 1;
    CRCACC = 0xFFFF;
    CRCXOR = 0x1021;
    CRCCON1bits.DLEN = 15;
    CRCCON1bits.PLEN = 15;
    CRCCON0bits.ACCM = 1;
    CRCCON0bits.SHIFTM = 0;
    CRCCON0bits.CRCGO = 1;
    SCANCON0bits.SCANGO = 1;
    while(SCANCON0bits.SCANGO);
    while(CRCCON0bits.BUSY);
    
    crc = CRCACC;
    
    while (1)
    {
        // Add your application code
    }
}

 

 

Will use 0x346C and 0x3493 value at 0x800 and 0x801 address in flash memory

https://www.lammertbies.nl/comm/info/crc-calculation.html

 

On-line CRC calculation and free library

On-line CRC calculation and free library Loading... Introduction on CRC calculations Whenever digital data is stored or interfaced, data corruption might occur. Since the beginning of computer science, people have been thinking of ways to deal with this ty

www.lammertbies.nl

To verify the CRC Calculation, I used On-line CRC Calculation and free library and put the value as "34633493" with Hex. And I got the calculated value as 0xF659 with CRC-CCITT (0xFFFF) and also I got the value as 0xF659 in MPLAB X debug mode as below.

 

 

CRC_PIC16F1618.X.zip
0.99MB

 

 

Posted by KennyShin
,

SAM V71 Xplained Ultra

 

 

SAM V71 Xplained Ultra
SAM V71 Xplained Ultra

The current through this switch is limited with the 390 Ohms resistor to IL = 250/Rlimit = 641 mA.
This is a typical value and according to the datasheet we can expect a minimum of 510 mA and a maximum of 800 mA.
The switch (TPS2113A) has a on-resistance of typically 84 mΩ (and maximal 110mΩ).

 

 

Target USB VBUS control:
Setting the VBUS_HOST_EN signal low will provide power to
VCC_TARGET_USB_P5V0 from VCC_P5V0 allowing target host mode operation.
The switch (STMPS2161) has an on-resistance of RDSon typ = 90mΩ, max = 110mΩ

Each FET in the power path has a RDSon of <50mΩ@VGS= -5V with a current of up to 20A
That means we can expect a maximum voltage drop across the FETs of 50mV@500mA, 100mV@1A and 200mV@2A.
For USB host mode we need a voltage between 4.4V to 5.25V so the drop that we have is ok and leaves some room for a host switch
on-resistance

SAM V71 Xplained Ultra

 

 

Posted by KennyShin
,

MyProject.zip
0.72MB

 

 

Input: SW0(PA9) Button input using external interrupt

Output: LED0 Toggle (Nearby SW0)

Operation: External Interrupt will be generated each edge such as rising and falling

              LED0 toggles when each external interrupt is generated

 

 

#include 

int main(void)
{
    /* Initializes MCU, drivers and middleware */
    atmel_start_init();

   /* Replace with your application code */
   EXTERNAL_IRQ_0_example();
   while (1) {
   }
}

main.c

 

 

#include "driver_examples.h"
#include "driver_init.h"
#include "utils.h"

static void button_on_PA9_pressed(void)
{
    gpio_toggle_pin_level(LED0);
}

/**
 * Example of using EXTERNAL_IRQ_0
 */
void EXTERNAL_IRQ_0_example(void)
{
    ext_irq_register(PIO_PA9_IDX, button_on_PA9_pressed);
}

driver_examples.c

Posted by KennyShin
,