News:

Let's find out together what makes a PIC Tick!

Main Menu

$if _type command

Started by SCV, Sep 06, 2022, 09:40 AM

Previous topic - Next topic

SCV

Hi,

Looking to search for instances where the device is a dsPIC33CK***. To save me listing every _DEVICE I though I could use _TYPE but manual (p448) doesn't list CK devices.$if _type = DSPIC33CK doesn't work.
What is the correct syntax here?

Thanks,
Tim.

Yasin

#1
I am doing this way.

$if _device = _18F87K90
    ....
$elseif _device = _18f8722
    ....
$endif

So it should have "_" at the beginning.

SCV

Thanks Yasin, I had put the underscore in my programme but not typed it correctly here.

To be clear...

$if _device = _33CK64MP205   works ok
$if _usart = 3               doesn't work
$if _type = _DSPIC33E        works ok
$if _type = _DSPIC33C        doesn't work
$if _type = _DSPIC33CK       doesn't work


tumbleweed

$if _usart = 3              doesn't work
The correct define for the 16-bit parts is '_uart' (no usarts in these parts)

$if _type = _DSPIC33C        doesn't work
There is no 'C' type defined... currently just 'CK'

$if _type = _DSPIC33CK      doesn't work
Works ok here

top204

The device information for the preprocessor is held in each device's ".def" file. For example, the DSPIC33CK64MP506 has the $defines:

$define _33CK_

' Microcontroller Information
$define _device _33CK64MP506
$define _core 33            ' Core type (24 or 33)
$define _oscdiv 2           ' Fosc division
$define _type _dsPIC33CK    ' Device type (_PIC24E, _PIC24F, _PIC24H, _dsPIC33CK, _dsPIC33CH, _dsPIC33E or _dsPIC33F)
$define _ram 8192           ' Total amount of RAM (in bytes)
$define _code 43776         ' Total amount of code memory available to a program (in bytes)
$define _dma_ram 8192       ' Amount of DMA RAM (in bytes)
$define _x_start 0x1000     ' Starting address of X RAM
$define _y_start 0x2000     ' Starting address of Y RAM
$define _dma_start 0x1000   ' Starting address of DMA RAM
$define _ports 4            ' Amount of ports
$define _adc 1              ' ADC available (1 or 0)
$define _adc_type 2         ' The type of code required for ADC
$define _eeprom 0           ' Amount of on-board eeprom (in bytes)
$define _uart 3             ' Amount of UART peripherals
$define _uart_type 2        ' The type of code required for UART
$define _usb 0              ' USB available (1 or 0)
$define _spi 3              ' Amount of SPI peripherals
$define _i2c 3              ' Amount of I2C peripherals
$define _i2c_type 2         ' The type of code required for I2C
$define _rtcc 0             ' RTCC available (1 or 0)
$define _pmp 1              ' PMP available (1 or 0)
$define _hpwm 9             ' Amount of Output Compare channels (Supported by the Compiler)
$define _hpwm_type 2        ' The type of code required for HPWM
$define _dac 2              ' Amount of DAC channels
$define _dma 3              ' Amount of DMA peripherals
$define _pps 1              ' PPS available (1 or 0)
$define _pps_type 2         ' The type of code required for PPS manipulation
$define _block 2            ' Size of the flash memory write segment (in 3-byte words)
$define _erase 1024         ' Size of the flash memory erase segment (in 3-byte words)

Yasin

#5
......

SCV

All working now, thanks everyone.

I was wrong to say it's not working, it's just the _DSPIC33CK wasn't highlighting as _DSPIC33E does. I remember now Les mentioning something about this before...
For the USART / UART it's a typo in the Proton 24 manual!

Cheers