Editing Programming Tips

Jump to navigation Jump to search

Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.

The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit.

Latest revision Your text
Line 85: Line 85:
  
  
===[http://chungyan5.no-ip.org/vc/trunk/posix/asm-dsPic/types.h?root=freertos_posix&view=markup <asm/types.h>]===
+
===<asm/types.h>===
 
*The following maps the basic data types:
 
*The following maps the basic data types:
 
   typedef unsigned char          __u8;
 
   typedef unsigned char          __u8;
Line 110: Line 110:
  
  
===[http://chungyan5.no-ip.org/vc/trunk/demo_posix/dspic/dspic33/linker/p33FJ256GP506.gld?root=freertos_posix&view=markup Custom Linker Script to Maximize Space for Constant Data]===
+
===Custom Linker Script to Maximize Space for Constant Data===
 
*Constant data declared using keyword '''const''' will be stored in the .const section in the flash memory.
 
*Constant data declared using keyword '''const''' will be stored in the .const section in the flash memory.
 
*Normally, during compilation, the linker will assign these data after the program code (.text section).
 
*Normally, during compilation, the linker will assign these data after the program code (.text section).
Line 160: Line 160:
  
  
===[http://chungyan5.no-ip.org/vc/trunk/demo_posix/dspic/dspic33/boot/boot.c?root=freertos_posix&view=markup System Clock]===
+
===System Clock===
 
*Each timer is 16-bit (i.e. counting from 0 to 65535).
 
*Each timer is 16-bit (i.e. counting from 0 to 65535).
 
*Prescale is the ratio between timer counts and system clock counts. Prescales of 1:1, 1:8, 1:64 and 1:256 are available.
 
*Prescale is the ratio between timer counts and system clock counts. Prescales of 1:1, 1:8, 1:64 and 1:256 are available.
Line 192: Line 192:
  
  
===[http://chungyan5.no-ip.org/vc/trunk/posix/asm-dsPic/system.h?root=freertos_posix&view=markup <asm/system.h>]===
+
===<asm/system.h>===
 
*Registers are involved in Interrupts includes:  
 
*Registers are involved in Interrupts includes:  
 
#Interrupt Flag Status (IFS0-IFS2) registers
 
#Interrupt Flag Status (IFS0-IFS2) registers
Line 209: Line 209:
  
 
==POSIX System Call and Drivers==
 
==POSIX System Call and Drivers==
*[http://chungyan5.no-ip.org/vc/trunk/demo_posix/dspic/drivers/devices.c?root=freertos_posix&view=markup POSIX System Calls] (open(), close(), read(), write(), lseek()) are used to access hardware devices related to data stream.
+
*POSIX System calls (open(), close(), read(), write(), lseek()) are used to access hardware devices related to data stream.
 
*The file descriptor return by open() for these devices are statically assigned at compile time.
 
*The file descriptor return by open() for these devices are statically assigned at compile time.
  
  
===[http://chungyan5.no-ip.org/vc/trunk/demo_posix/dspic/drivers/uart.c?root=freertos_posix&view=markup UART]===
+
===UART===
 
*Serves as the default communication channel for STDIN, STDOUT and STDERR.
 
*Serves as the default communication channel for STDIN, STDOUT and STDERR.
 
*Implementation of this driver allows transparent operation of printf() in standard C library.  
 
*Implementation of this driver allows transparent operation of printf() in standard C library.  
  
  
===[http://chungyan5.no-ip.org/vc/trunk/demo_posix/dspic/drivers/i2c.c?root=freertos_posix&view=markup I<sup>2</sup>C]===
+
===I<sup>2</sup>C===
 
*A number of I2C devices can be added using this driver (e.g. I2C DAC, I2C EEPROM, etc)
 
*A number of I2C devices can be added using this driver (e.g. I2C DAC, I2C EEPROM, etc)
 
*Two lines are devoted for the serial communication. SCL for clock, SDA for data.
 
*Two lines are devoted for the serial communication. SCL for clock, SDA for data.
Line 232: Line 232:
  
  
===[http://chungyan5.no-ip.org/vc/trunk/demo_posix/dspic/drivers/adc.c?root=freertos_posix&view=markup ADC]===
+
===ADC===
 
*12-bit ADC: (Max 18 Channels)
 
*12-bit ADC: (Max 18 Channels)
 
*ADC uses DMA to buffer the adc data.
 
*ADC uses DMA to buffer the adc data.
Line 238: Line 238:
  
  
===[http://chungyan5.no-ip.org/vc/trunk/demo_posix/dspic/drivers/pwm.c?root=freertos_posix&view=markup Simple PWM (Output Compare Module)]===
+
===Simple PWM (Output Compare Module)===
 
*The PWM module consists of 8 channels using the output compare module of dsPic.
 
*The PWM module consists of 8 channels using the output compare module of dsPic.
 
*These channels are locate at pin 46 (OC1), 49 (OC2), 50 (OC3), 51 (OC4), 52 (OC5), 53 (OC6), 54 (OC7), 55 (OC8). These pins are shared with port D.
 
*These channels are locate at pin 46 (OC1), 49 (OC2), 50 (OC3), 51 (OC4), 52 (OC5), 53 (OC6), 54 (OC7), 55 (OC8). These pins are shared with port D.
Line 283: Line 283:
  
  
=== run-time self-programming flash ===
+
===Flash-emulated EEPROM===
 
 
Some chips allow programs to write to flash memory (program memory);
 
this process is called RTSP (run-time self-programming).
 
 
 
[http://chungyan5.no-ip.org/vc/trunk/demo_posix/dspic/drivers/flash_eeprom.c?root=freertos_posix&view=markup Flash-emulated EEPROM]
 
 
*Using built-in functions __builtin_tblpage(), __builtin_tbloffset() to set special-purpose registers to access flash memory
 
*Using built-in functions __builtin_tblpage(), __builtin_tbloffset() to set special-purpose registers to access flash memory
*Using [http://chungyan5.no-ip.org/vc/trunk/demo_posix/dspic/drivers/rtsp.s?root=freertos_posix&view=markup assembly code] to read and write flash memory.
+
*Using assembly code to read and write flash memory.
 
 
[http://electronics.stackexchange.com/questions/20970/trying-to-get-my-head-around-rtsp-and-failing-miserably "Trying to get my head around RTSP"]
 
  
The KeaDrone project has some code for reading and writing flash on a PIC24F chip:
 
[http://keadrone.googlecode.com/svn-history/r2/trunk/KeaDrone/24F-source/flashSaveOperations.c ]
 
  
 
==DSP Library==
 
==DSP Library==
Line 306: Line 297:
 
#Transform
 
#Transform
 
#Control
 
#Control
 
  
 
===Data Types===
 
===Data Types===
Line 323: Line 313:
 
**Floating point values can be converted to Fractional values using: '''fr = Float2Fract(fo);''' or '''fr = Q15(fo);''' for fo = [-1, 1-2<sup>-15</sup>]
 
**Floating point values can be converted to Fractional values using: '''fr = Float2Fract(fo);''' or '''fr = Q15(fo);''' for fo = [-1, 1-2<sup>-15</sup>]
 
**Float2Fract() is same as Q15(), except having saturation control. When +ve >= 1, answer = 2<sup>15</sup>-1 = 32767 (0x7FFF). When -ve < -1, answer = -2<sup>15</sup> = -32767 (0x8000)
 
**Float2Fract() is same as Q15(), except having saturation control. When +ve >= 1, answer = 2<sup>15</sup>-1 = 32767 (0x7FFF). When -ve < -1, answer = -2<sup>15</sup> = -32767 (0x8000)
 
 
===Fast Fourier Transform===
 
*to be added
 

Please note that all contributions to OpenCircuits may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see OpenCircuits:Copyrights for details). Do not submit copyrighted work without permission!

Cancel Editing help (opens in new window)