Skip to content

Instantly share code, notes, and snippets.

@samsch

samsch/README.md Secret

Last active December 17, 2017 03:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save samsch/9860d81ce7841024c98a441baef754a2 to your computer and use it in GitHub Desktop.
Save samsch/9860d81ce7841024c98a441baef754a2 to your computer and use it in GitHub Desktop.
SDCC minimal test code for 25k50 on P-Star

RC2, RC6, and RC7 are connected to a 220 ohm resistor and an LED in series then to ground. Each LED is tested working.

Running the above program, the RC7 measure about GND, RC6 is about 1.5v (and about 3.3v on the onboard red LED, which is on), and RC2 appears to be floating (random very low voltages).

Program is compiled with /opt/sdcc/bin/sdcc --use-non-free -mpic16 -ppic18f25k50 main.c. The linker script is modified from

CODEPAGE   NAME=page       START=0x0               END=0x7FFF

to

CODEPAGE   NAME=page       START=0x2000            END=0x7FFF
#define __SDCC_PIC18F25K50
#define _XTAL_FREQ 48000000
#include <pic18fregs.h>
#include <delay.h>
#define LASERLED(on) { TRISCbits.RC7 = !on; }
#define READYLED(on) { TRISCbits.RC6 = !on; }
#define RELOADLED(on) { TRISCbits.RC2 = !on; }
#define TRIGGER PORTAbits.RA1
void main()
{
T0CON = 0;
//Set almost all pins to be outputs.
TRISA = 0x02; // A1 is input
TRISB = 0xc3; // RB0 and RB1 are inputs for I2C
TRISC = 0xc4;
ANSELA = 0; //Turn off all analog channels. 0x0F is all off.
ANSELB = 0;
ANSELC = 0;
LATA = 0;
LATB = 0;
LATC = 0xc4;
while(1)
{
LASERLED(1);
READYLED(1);
RELOADLED(1);
delay1mtcy(48);
LASERLED(0);
READYLED(0);
RELOADLED(0);
delay1mtcy(48);
}
}
:020000040000FA
:040000006AEF10F0A3
:10200000E806E56E630E1FEC10F0630E4BEC10F06B
:10201000090E5EEC10F0E45011E000D0E56E630EA6
:102020001FEC10F0630E4BEC10F0090E5EEC10F09C
:1020300000D000D00000E450E82EF0D71200E806EF
:10204000E56E090E38EC10F0630E5EEC10F0E45013
:102050000EE000D0E56E090E38EC10F0630E5EEC79
:1020600010F000D000D00000E450E82EF3D71200AA
:10207000E806E56E630E5EEC10F0E4500BE000D075
:10208000E56E630E5EEC10F000D000D00000E4506E
:10209000E82EF6D71200E806E56E090E5EEC10F0A9
:1020A000E4500BE000D0E56E090E5EEC10F000D0BD
:1020B000E450000000D0E82EF6D71200E806000039
:1020C000E85007E000D000D000D000D00000E82E9B
:1020D000FAD7120011EEFFF021EEFFF0F86AA68E9B
:1020E000A69CE9680E0EEA6E0068ED6A0050FDE1FC
:1020F000BE0EF66E210EF76E000EF86E0900F5CFDB
:1021000005F00900F5CF06F034D00900F5CF00F056
:102110000900F5CF01F00900F5CF02F00900090030
:10212000F5CFE9FF0900F5CFEAFF09000900090032
:10213000F5CF03F00900F5CF04F009000900F6CF50
:1021400007F0F7CF08F0F8CF09F000C0F6FF01C0A4
:10215000F7FF02C0F8FF03D00900F5CFEEFF03063A
:10216000FBE20406F9E207C0F6FF08C0F7FF09C06A
:10217000F8FF0506CAE20606C8E2C0EC10F0FFD779
:10218000D56A020E926EC30E936EC40E946E0F014A
:102190005B6B0F015C6B0F015D6B896A8A6AC40E11
:1021A0008B6E949E949C9494300E00EC10F0948E60
:1021B000948C9484300E00EC10F0F3D712000100E0
:0E21C000CC21000060000000010000000000C3
:00000001FF
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment