Data Types

Article by:
Date Published:
Last Modified:

Standard Data Types

Note: The pre-defined variable types that come with the PSoC programming suites are defined both with and without the _t suffix that most people use to define a typedef (e.g. uint8_t). I recommend using the version with the underscore, as this increases portability (this is also supported by Linux and other Unix-like systems). It is better practice to use the data types whose size is explicitly stated (e.g. uint32_t rather than unsigned int as the latter’s size is platform-dependant). The following data types are valid for all PSoC families.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
// Standard C data types (implicit sizes)
char
short
int
long
float
double

// Types available through <stdint.h>
int8_t
uint8_t
int16_t
uint16_t
int32_t
uint32_t
int64_t
uint64_t
size_t

// Cypress-defined data types (explicit sizes)
// Note that 64-bit data types are only availiable
// with the _t suffix
int8
uint8
int16
uint16
int32
uint32

Standard C Variable Type Sizes On PSoC 5

Data TypeSize (bytes)RangeDecimal Precision (places)printf() identifier
char10-255%c
short2%i
int4%i
unsigned int4%u
long4%i
float47%f
double815%f

These were discovered using the sizeof() command, and printing the result to a debug terminal.


Authors

Geoffrey Hunter

Dude making stuff.

Creative Commons License
This work is licensed under a Creative Commons Attribution 4.0 International License .

Tags

    comments powered by Disqus